001: /*
002: * JFolder, Copyright 2001-2006 Gary Steinmetz
003: *
004: * Distributable under LGPL license.
005: * See terms of license at gnu.org.
006: */
007:
008: package org.jfolder.common.files;
009:
010: //base classes
011: import java.util.ArrayList;
012:
013: //project specific classes
014:
015: //other classes
016:
017: public class SimpleWebPageTagMacro implements WebPageTagMacro {
018:
019: //
020: //
021: private String name = null;
022: private String resultType = null;
023: private ArrayList paramNames = null;
024: private ArrayList paramTypes = null;
025:
026: //
027: //
028: //
029: private SimpleWebPageTagMacro(String inName, String inResultType,
030: ArrayList inParamNames, ArrayList inParamTypes) {
031: //
032: this .name = inName;
033: this .resultType = inResultType;
034: this .paramNames = inParamNames;
035: this .paramTypes = inParamTypes;
036: }
037:
038: public final static SimpleWebPageTagMacro newInstance(
039: String inName, String inResultType, ArrayList inNames,
040: ArrayList inTypes) {
041:
042: SimpleWebPageTagMacro outValue = null;
043:
044: outValue = new SimpleWebPageTagMacro(inName, inResultType,
045: inNames, inTypes);
046:
047: return outValue;
048: }
049:
050: //
051: public String getName() {
052: return this .name;
053: }
054:
055: //
056: public String[] getParameterNames() {
057: return fromArrayListToStrings(this .paramNames);
058: }
059:
060: //
061: public String[] getParameterTypes() {
062: return fromArrayListToStrings(this .paramTypes);
063: }
064:
065: //
066: public String getResultType() {
067: return this .resultType;
068: }
069:
070: //
071: public boolean isSignatureMatch(String inName,
072: String inParameterTypes[]) {
073:
074: boolean outValue = true;
075:
076: outValue &= inName.equals(this .name);
077:
078: if (this .paramTypes.size() == inParameterTypes.length) {
079:
080: for (int i = 0; i < this .paramTypes.size(); i++) {
081: String nextParamType = ((String) this .paramTypes.get(i));
082: outValue &= nextParamType.equals(inParameterTypes[i]);
083: }
084: } else {
085: outValue &= false;
086: }
087:
088: return outValue;
089: }
090:
091: //
092: public boolean isSignatureValid() {
093: return true;
094: }
095:
096: //
097: public int getParameterCount() {
098: return this .paramNames.size();
099: }
100:
101: public String getParameterName(int inIndex) {
102: return ((String) this .paramNames.get(inIndex));
103: }
104:
105: public String getParameterType(int inIndex) {
106: return ((String) this .paramTypes.get(inIndex));
107: }
108:
109: private final static String[] fromArrayListToStrings(
110: ArrayList inValue) {
111:
112: String outValue[] = new String[inValue.size()];
113:
114: //
115: for (int i = 0; i < inValue.size(); i++) {
116: outValue[i] = ((String) inValue.get(i));
117: }
118:
119: return outValue;
120: }
121: }
|