001: /*
002: Copyright (c) 2007, Dennis M. Sosnoski
003: All rights reserved.
004:
005: Redistribution and use in source and binary forms, with or without modification,
006: are permitted provided that the following conditions are met:
007:
008: * Redistributions of source code must retain the above copyright notice, this
009: list of conditions and the following disclaimer.
010: * Redistributions in binary form must reproduce the above copyright notice,
011: this list of conditions and the following disclaimer in the documentation
012: and/or other materials provided with the distribution.
013: * Neither the name of JiBX nor the names of its contributors may be used
014: to endorse or promote products derived from this software without specific
015: prior written permission.
016:
017: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
018: ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
019: WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
020: DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
021: ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
022: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
023: LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
024: ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
025: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
026: SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
027: */
028:
029: package org.jibx.ws.wsdl;
030:
031: import java.util.Collection;
032: import java.util.List;
033:
034: import org.jibx.binding.generator.CustomBase;
035: import org.jibx.runtime.IUnmarshallingContext;
036: import org.jibx.runtime.JiBXException;
037: import org.jibx.runtime.impl.UnmarshallingContext;
038:
039: /**
040: * Method throws customization information. This just defines the actual
041: * exceptions to be handled for a method
042: */
043: public class ThrowsCustom extends CustomBase {
044: // value customization information
045: private String m_type;
046: private List m_documentation;
047:
048: /**
049: * Constructor.
050: *
051: * @param parent
052: * @param type fully-qualified class name thrown
053: */
054: protected ThrowsCustom(NestingBase parent, String type) {
055: super (parent);
056: m_type = type;
057: }
058:
059: /**
060: * Get fully-qualified class name thrown.
061: *
062: * @return type
063: */
064: public String getType() {
065: return m_type;
066: }
067:
068: /**
069: * Get value documentation node list. This method should only be used after
070: * the {@link #complete(List)} method is called.
071: *
072: * @return list of documentation nodes (<code>null</code> if none)
073: */
074: public List getDocumentation() {
075: return m_documentation;
076: }
077:
078: /**
079: * Complete customization information using supplied default documentation.
080: *
081: * @param docs default documentation text (<code>null</code> if none)
082: */
083: /*package*/void complete(List docs) {
084: if (m_documentation == null) {
085: m_documentation = docs;
086: }
087: }
088:
089: /**
090: * Parameter value unmarshalling factory. This gets the containing element
091: * and the name so that the standard constructor can be used.
092: *
093: * @param ictx
094: * @return created instance
095: * @throws JiBXException
096: */
097: private static ThrowsCustom throwsFactory(IUnmarshallingContext ictx)
098: throws JiBXException {
099: UnmarshallingContext uctx = (UnmarshallingContext) ictx;
100: Object parent = uctx.getStackTop();
101: int depth = 0;
102: if (parent instanceof Collection) {
103: parent = uctx.getStackObject(++depth);
104: }
105: return new ThrowsCustom((OperationCustom) parent, uctx
106: .attributeText(null, "class"));
107: }
108: }
|