001: /*
002: * $Id: FunctionRequest.java,v 1.21 2007/09/18 08:45:05 agoubard Exp $
003: *
004: * Copyright 2003-2007 Orange Nederland Breedband B.V.
005: * See the COPYRIGHT file for redistribution and use restrictions.
006: */
007: package org.xins.server;
008:
009: import org.xins.common.MandatoryArgumentChecker;
010: import org.xins.common.collections.PropertyReader;
011: import org.xins.common.collections.PropertyReaderUtils;
012: import org.xins.common.xml.Element;
013:
014: /**
015: * Function request. Consists of a function name, a set of parameters and a
016: * data section. The function name is mandatory, while there may not be any
017: * parameters nor data section.
018: *
019: * @version $Revision: 1.21 $ $Date: 2007/09/18 08:45:05 $
020: * @author <a href="mailto:anthony.goubard@japplis.com">Anthony Goubard</a>
021: * @author <a href="mailto:ernst@ernstdehaan.com">Ernst de Haan</a>
022: *
023: * @since XINS 1.2.0
024: */
025: public class FunctionRequest {
026:
027: /**
028: * The name of the function. This field is never <code>null</code>.
029: */
030: private final String _functionName;
031:
032: /**
033: * The parameters of the function. This field is never <code>null</code>
034: */
035: private final PropertyReader _parameters;
036:
037: /**
038: * The data section of the function. If there is none, then this field is
039: * <code>null</code>.
040: */
041: private final Element _dataElement;
042:
043: /**
044: * Flag indicating whether the function should be skipped or not.
045: */
046: private final boolean _skipFunctionCall;
047:
048: /**
049: * Creates a new <code>FunctionRequest</code>. The function name must be
050: * specified.
051: *
052: * @param functionName
053: * the name of the function, cannot be <code>null</code>.
054: *
055: * @param parameters
056: * the parameters of the function requested, cannot be
057: * <code>null</code>.
058: *
059: * @param dataElement
060: * the data section of the input request, can be <code>null</code>.
061: *
062: * @throws IllegalArgumentException
063: * if <code>functionName == null</code>.
064: */
065: public FunctionRequest(String functionName,
066: PropertyReader parameters, Element dataElement)
067: throws IllegalArgumentException {
068: this (functionName, parameters, dataElement, false);
069: }
070:
071: /**
072: * Creates a new <code>FunctionRequest</code>. The function name must be
073: * specified.
074: *
075: * @param functionName
076: * the name of the function, cannot be <code>null</code>.
077: *
078: * @param parameters
079: * the parameters of the function requested, cannot be
080: * <code>null</code>.
081: *
082: * @param dataElement
083: * the data section of the input request, can be <code>null</code>.
084: *
085: * @param skipFunctionCall
086: * <code>true</code> if the function shouldn't be executed, <code>false</code> otherwise.
087: *
088: * @throws IllegalArgumentException
089: * if <code>functionName == null</code>.
090: *
091: * @since XINS 2.0
092: */
093: public FunctionRequest(String functionName,
094: PropertyReader parameters, Element dataElement,
095: boolean skipFunctionCall) throws IllegalArgumentException {
096:
097: // Check preconditions
098: MandatoryArgumentChecker.check("functionName", functionName);
099:
100: // Store the function name (never null)
101: _functionName = functionName;
102:
103: // Store the parameters, make sure this is never null
104: if (parameters == null) {
105: _parameters = PropertyReaderUtils.EMPTY_PROPERTY_READER;
106: } else {
107: _parameters = parameters;
108: }
109:
110: // Store the data section, or null if there is none
111: _dataElement = dataElement;
112:
113: _skipFunctionCall = skipFunctionCall;
114: }
115:
116: /**
117: * Gets the name of the function.
118: *
119: * @return
120: * the name of the function, never <code>null</code>.
121: *
122: * @since XINS 2.0
123: */
124: public String getFunctionName() {
125: return _functionName;
126: }
127:
128: /**
129: * Gets the parameters of the function. The returned
130: * {@link PropertyReader} instance is unmodifiable.
131: *
132: * @return
133: * the parameters of the function, never <code>null</code>.
134: *
135: * @since XINS 2.0
136: */
137: public PropertyReader getParameters() {
138: return _parameters;
139: }
140:
141: /**
142: * Gets the data section of the request.
143: *
144: * @return
145: * the data section, or <code>null</code> if there is none.
146: *
147: * @since XINS 2.0
148: */
149: public Element getDataElement() {
150: return _dataElement;
151: }
152:
153: /**
154: * Gets whether the function should be executed or not.
155: *
156: * @return
157: * <code>true</code> if the function shouldn't be executed, <code>false</code> otherwise.
158: *
159: * @since XINS 2.0
160: */
161: public boolean shouldSkipFunctionCall() {
162: return _skipFunctionCall;
163: }
164: }
|