001: /*
002: Copyright (c) 2004-2005, 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: /**
032: * Reference to a message within an operation. Since messages may be referenced
033: * as input, output, or fault messages, the appropriate type is tracked by this
034: * class, along with the actual message.
035: *
036: * @author Dennis M. Sosnoski
037: */
038: public class MessageReference {
039: /** Reference to message as input. */
040: public static final int INPUT_REFERENCE = 0;
041:
042: /** Reference to message as output. */
043: public static final int OUTPUT_REFERENCE = 1;
044:
045: /** Reference to message as fault. */
046: public static final int FAULT_REFERENCE = 2;
047:
048: /** Type of message reference. */
049: private int m_usage;
050:
051: /** Actual message. */
052: private Message m_message;
053:
054: /**
055: * Internal constructor used with JiBX binding.
056: *
057: * @param usage reference type code
058: */
059: private MessageReference(int usage) {
060: m_usage = usage;
061: }
062:
063: /**
064: * Constructor from part and element names.
065: *
066: * @param usage reference type code
067: * @param msg referenced message
068: */
069: public MessageReference(int usage, Message msg) {
070: m_usage = usage;
071: m_message = msg;
072: }
073:
074: /**
075: * Check if reference is to message as input.
076: *
077: * @return <code>true</code> if input reference, <code>false</code> if not
078: */
079: public boolean isInput() {
080: return m_usage == INPUT_REFERENCE;
081: }
082:
083: /**
084: * Check if reference is to message as output.
085: *
086: * @return <code>true</code> if output reference, <code>false</code> if not
087: */
088: public boolean isOutput() {
089: return m_usage == OUTPUT_REFERENCE;
090: }
091:
092: /**
093: * Check if reference is to message as fault.
094: *
095: * @return <code>true</code> if fault reference, <code>false</code> if not
096: */
097: public boolean isFault() {
098: return m_usage == FAULT_REFERENCE;
099: }
100:
101: /**
102: * Get referenced message.
103: *
104: * @return referenced message
105: */
106: public Message getMessage() {
107: return m_message;
108: }
109:
110: /**
111: * Factory for creating input message reference templates. The actual
112: * referenced message information needs to be set separately.
113: * TODO: use these as an example
114: *
115: * @return created reference
116: */
117: private static MessageReference inputReferenceFactory() {
118: return new MessageReference(INPUT_REFERENCE);
119: }
120:
121: /**
122: * Factory for creating output message reference templates. The actual
123: * referenced message information needs to be set separately.
124: *
125: * @return created reference
126: */
127: private static MessageReference outputReferenceFactory() {
128: return new MessageReference(OUTPUT_REFERENCE);
129: }
130:
131: /**
132: * Factory for creating fault message reference templates. The actual
133: * referenced message information needs to be set separately.
134: *
135: * @return created reference
136: */
137: private static MessageReference faultReferenceFactory() {
138: return new MessageReference(FAULT_REFERENCE);
139: }
140: }
|