001: /**
002: * Objective Database Abstraction Layer (ODAL)
003: * Copyright (c) 2004, The ODAL Development Group
004: * All rights reserved.
005: * For definition of the ODAL Development Group please refer to LICENCE.txt file
006: *
007: * Distributable under LGPL license.
008: * See terms of license at gnu.org.
009: */package com.completex.objective.components.persistency;
010:
011: /**
012: * Call parameter collection
013: *
014: * @author Gennady Krizhevsky
015: */
016: public class CallParameters extends AbstractParameters {
017:
018: public CallParameters() {
019: }
020:
021: /**
022: * @see AbstractParameters#AbstractParameters(int)
023: */
024: public CallParameters(int capacity) {
025: super (capacity);
026: }
027:
028: /**
029: * @see AbstractParameters#AbstractParameters(AbstractParameters)
030: */
031: public CallParameters(CallParameters parameters) {
032: super (parameters);
033: }
034:
035: /**
036: *
037: * Constructs CallParameters from array of values.
038: * If the array element is of Parameter type it is simply added,
039: * ff not then new parameter with null column type gets created and added to this collection.
040: * @param parameters array of CallParameter elements
041: * @throws OdalRuntimePersistencyException if not all parameters are not instances of CallParameter
042: */
043: public CallParameters(Parameter[] parameters) {
044: super (parameters);
045: }
046:
047: /**
048: * Validates parameter type
049: *
050: * @param parameter parameter
051: * @throws OdalRuntimePersistencyException parameter is not instance of CallParameter
052: */
053: protected void validateParameterType(Parameter parameter) {
054: super .validateParameterType(parameter);
055: if (!(parameter instanceof CallParameter)) {
056: throw new OdalRuntimePersistencyException(
057: "Expected type CallParameter, received: "
058: + parameters);
059: }
060: }
061:
062: /**
063: * <p> Appends value to end of this collection.
064: * @param type type column type of the field this parameter corresponds to
065: * @param value value of this parameter.
066: * @return added CallParameter
067: * @throws OdalRuntimePersistencyException if the value is already of Parameter type,
068: * in which case add(Object value) method should be used
069: */
070: public CallParameter add(ColumnType type, Object value,
071: CallParameter.Mode mode) {
072: assertValueNotParameter(value);
073: return add0(type, value, mode);
074: }
075:
076: /**
077: * <p> Appends value to parameter collection. If value is of Parameter class - adds it,
078: * otherwise - creates new Parameter with null type and adds it to the end of this collection.
079: *
080: * @param callParameter value of this parameter.
081: * @return added Parameter or value if it is of Parameter class
082: */
083: public CallParameter add(CallParameter callParameter) {
084: if (callParameter == null) {
085: throw new OdalRuntimePersistencyException(
086: "Cannot add empty parameter");
087: }
088: parameters.add(callParameter);
089: return callParameter;
090: }
091:
092: /**
093: * <p> Appends value to end of this collection.
094: *
095: * @param type type column type of the field this parameter corresponds to
096: * @param value value of this parameter.
097: * @return added CallParameter
098: */
099: protected CallParameter add0(ColumnType type, Object value,
100: CallParameter.Mode mode) {
101: CallParameter parameter = new CallParameter(value, mode, type);
102: parameters.add(parameter);
103: return parameter;
104: }
105:
106: /**
107: * Appends all of the parameters in the specified argParameters to the end of
108: * this collection
109: *
110: * @param argParameters the parameters to be inserted into this collection.
111: */
112: public void addAll(AbstractParameters argParameters) {
113: super.addAll(argParameters);
114: }
115:
116: }
|