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.config.instance;
009:
010: //base classes
011: import java.util.HashMap;
012: import org.w3c.dom.Document;
013:
014: //project specific classes
015: import org.jfolder.common.UnexpectedSystemException;
016: import org.jfolder.common.tagging.BaseConceptTagPreferences;
017: import org.jfolder.common.tagging.ConceptTag;
018: import org.jfolder.common.tagging.ConceptTagCallContext;
019: import org.jfolder.common.tagging.ConceptTagMenuBranch;
020: import org.jfolder.common.tagging.ConceptTagPreferences;
021: import org.jfolder.common.tagging.ConceptTagPreferencesHelper;
022: import org.jfolder.common.tagging.ConceptTagProperties;
023: import org.jfolder.common.tagging.ConceptTagSetHolder;
024: import org.jfolder.common.tagging.DetermineClassConceptTagContext;
025: import org.jfolder.common.tagging.DetermineValueAndClassConceptTagContext;
026: import org.jfolder.common.tagging.InitializeConceptTagContext;
027: import org.jfolder.common.tagging.RootConceptTagHolder;
028: import org.jfolder.common.utils.misc.MiscHelper;
029:
030: //other classes
031:
032: public class ConfigInstanceTagPreferences extends
033: BaseConceptTagPreferences {
034:
035: //private final static String CMT_BASE_NAMESPACE =
036: // "http://www.jfolder.org/dtds/apps/config/instance/";
037: //
038: //private final static String CMT_NAMESPACE_V1 =
039: // CMT_BASE_NAMESPACE + "v1/";
040: //private final static String CMT_NAMESPACE_V1_BASE =
041: // CMT_NAMESPACE_V1 + "base.dtd";
042: //private final static String CMT_NAMESPACE_V1_CORE =
043: // CMT_NAMESPACE_V1 + "core.dtd";
044: //private final static String CMT_NAMESPACE_V1_RETURNABLE =
045: // CMT_NAMESPACE_V1 + "returnable.dtd";
046: //
047: //private final static String CMT_NAME_V1_TEXT = "text";
048: //private final static String CMT_NAME_V1_COMPOUND = "compound";
049: //
050: //private final static String CMT_ATTR_V1_CONSTRAINT = "constraint";
051: //
052: //private final static String CMT_HANDLE_CONJUCTION = "$";
053: //
054: //private final static String ROOT_CONSTRAINT = "root";
055: //
056: //private final static String UNCONSTRAINED_SYMBOL = "@";
057:
058: //
059: private ConceptTagSetHolder ctsh = null;
060: //
061: private boolean validateOnlyMode = false;
062:
063: //
064: private RootConceptTagHolder rcth = null;
065:
066: //private Exception rcthException = null;
067: //private Exception initException = null;
068:
069: public ConfigInstanceTagPreferences() {
070: //
071: //this.initException = new UnexpectedSystemException(
072: // "Already Set" + this);
073: //
074: this .ctsh = new ConceptTagSetHolder(getPreferencesHandle());
075: ConceptTagProperties ctProps = ConceptTagProperties
076: .newInstance(new String[0]);
077: this .ctsh
078: .registerConceptTag(
079: ConceptTagPreferencesHelper.CTP_PREF_NS__CONFIG_INSTANCE__V1_BASE,
080: ConceptTagPreferencesHelper.CTP_PREF_ROOT_LOCAL_NAME__COMMON,
081: "org.jfolder.config.instance.v1.RootV1ConfigInstanceTag",
082: ctProps);
083: //
084: this .validateOnlyMode = false;
085: }
086:
087: //
088: public void initialize(ConceptTagCallContext inCtcc) {
089: throw UnexpectedSystemException.notImplemented();
090: }
091:
092: //
093: public void bubba() {
094: throw UnexpectedSystemException.unknownState();
095: }
096:
097: //
098: public void setRootHolder(RootConceptTagHolder inRcth) {
099: if (this .rcth != null) {
100: throw new UnexpectedSystemException("Already set");
101: //throw new UnexpectedSystemException(
102: // "Already Set " + this, this.rcthException);
103: } else {
104: //MiscHelper.writeMessage(this, (new Exception()));
105: //this.rcthException = new UnexpectedSystemException(
106: // this.initException);
107: this .rcth = inRcth;
108: }
109: }
110:
111: public RootConceptTagHolder getRootHolder() {
112: return this .rcth;
113: }
114:
115: //
116: public boolean isStaticUsed() {
117: return true;
118: }
119:
120: public String getStaticNamespace() {
121: return ConceptTagPreferencesHelper.CTP_PREF_NS__COMMON_COMPONENTS__V1;
122: }
123:
124: public String getStaticName() {
125: return ConceptTagPreferencesHelper.CTP_PREF_STATIC_LOCAL_NAME__COMMON;
126: }
127:
128: //
129: public boolean isCompoundUsed() {
130: return true;
131: }
132:
133: public String getCompoundNamespace() {
134: return ConceptTagPreferencesHelper.CTP_PREF_NS__COMMON_COMPONENTS__V1;
135: }
136:
137: public String getCompoundName() {
138: return ConceptTagPreferencesHelper.CTP_PREF_COMPOUND_LOCAL_NAME__COMMON;
139: }
140:
141: //
142: public boolean isNonTerminalCharacterDataStripped() {
143: return true;
144: }
145:
146: //
147: public boolean isConstraintUsed() {
148: return true;
149: }
150:
151: public String getConstraintNamespace() {
152: return ConceptTagPreferencesHelper.CTP_PREF_NS__COMMON_COMPONENTS__V1;
153: }
154:
155: public String getConstraintName() {
156: return ConceptTagPreferencesHelper.CTP_PREF_CONSTRAINT_LOCAL_NAME__COMMON;
157: }
158:
159: //
160: public boolean isStyleUsed() {
161: return false;
162: }
163:
164: public String getStyleNamespace() {
165: return null;
166: }
167:
168: public String getStyleName() {
169: return null;
170: }
171:
172: //
173: public boolean isUnconstrainedAllowed() {
174: return false;
175: }
176:
177: public String getUnconstrainedSymbol() {
178: return ConceptTagPreferencesHelper.CTP_PREF_UNCONSTRAINED_SYMBOL_COMMON;
179: }
180:
181: //
182: public String getRootConstraint() {
183: return ConceptTagPreferencesHelper.CTP_PREF_ROOT_CONSTRAINT__COMMON;
184: }
185:
186: public String getRootHandle() {
187: return (getRootConstraint() + getHandleConjunction() + "0");
188: }
189:
190: //
191: public String getHandleConjunction() {
192: return ConceptTagPreferencesHelper.CTP_PREF_HANDLE_CONJUNCTION__COMMON;
193: }
194:
195: //
196: public ConceptTagSetHolder getSetHolder() {
197:
198: ConceptTagSetHolder outValue = null;
199:
200: outValue = this .ctsh;
201:
202: return outValue;
203: }
204:
205: public ConceptTagMenuBranch getMenuBase() {
206: throw UnexpectedSystemException.notImplemented();
207: }
208:
209: //
210: public String getRootClassName() {
211: return ("org.jfolder.config.instance.v1.RootV1ConfigInstanceTag");
212: }
213:
214: //
215: public InitializeConceptTagContext getInitializeContext() {
216: return new InitializeConfigInstanceTagContext(this );
217: }
218:
219: public DetermineClassConceptTagContext getReturnClassContext() {
220: throw UnexpectedSystemException.notImplemented();
221: }
222:
223: public DetermineValueAndClassConceptTagContext getDetermineValueAndClassContext() {
224: throw UnexpectedSystemException.notImplemented();
225: }
226:
227: //
228: public ConceptTag createUnknownConceptTag(String inNs, String inName) {
229:
230: throw new UnexpectedSystemException("Unknown Script Tag - "
231: + "Namespace = ('" + inNs + "'), Name = ('" + inName
232: + "')");
233: }
234:
235: public HashMap getDefaultNamespaceAssignments() {
236: return new HashMap();
237: }
238:
239: public String getAttributeConstraintName() {
240: return ConceptTagPreferencesHelper.CTP_PREF_ATTRIBUTE_LOCAL_NAME__COMMON;
241: }
242:
243: public String getStyleConstraintName() {
244: return ConceptTagPreferencesHelper.CTP_PREF_STYLE_LOCAL_NAME__COMMON;
245: }
246:
247: //
248: public void setValidateOnlyMode(boolean inMode) {
249: this .validateOnlyMode = inMode;
250: }
251:
252: public boolean isValidateOnlyMode() {
253: return this .validateOnlyMode;
254: }
255:
256: //
257: public boolean isAttributeAndStyleForbidden() {
258: return true;
259: }
260:
261: //public boolean isGeneralContentForbidden() {
262: // return true;
263: //}
264: //
265: public void correctForSpecialCharactersAndElements(Document inDoc) {
266: //no corrections needed
267: }
268:
269: //
270: public boolean isFileSystemPresent() {
271: return false;
272: }
273:
274: public String getPreferencesHandle() {
275: return ConceptTagPreferencesHelper.CTP_PREF_HANDLE__CONFIG_INSTANCE;
276: }
277: }
|