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.entity.properties;
009:
010: //base classes
011:
012: //project specific classes
013: import org.jfolder.common.UnexpectedSystemException;
014: import org.jfolder.common.entity.SystemEntity;
015: import org.jfolder.common.entity.SystemEntityUpdates;
016: import org.jfolder.common.entity.SystemEntityUpdatesContext;
017: import org.jfolder.common.tagging.AppraiseConceptTagContext;
018: import org.jfolder.common.tagging.ConceptTag;
019: import org.jfolder.common.tagging.ConceptTagCharacteristic;
020: import org.jfolder.common.tagging.ConceptTagCharacteristicHolder;
021: import org.jfolder.common.tagging.ConceptTagConstraint;
022: import org.jfolder.common.tagging.ConceptTagConstraintHolder;
023: import org.jfolder.common.tagging.ConceptTagPreferences;
024: import org.jfolder.common.tagging.DynamicConceptTagConstraintContext;
025: import org.jfolder.common.tagging.InitializeConceptTagContext;
026: import org.jfolder.common.tagging.RootConceptTagHolder;
027: import org.jfolder.common.tagging.StaticConceptTagConstraintContext;
028: import org.jfolder.common.tagging.StudioConceptTagInstanceInfoContext;
029: import org.jfolder.common.tagging.StudioConceptTagTypeInfoContext;
030:
031: //other classes
032:
033: public class SubSpaceSystemEntityProperties implements
034: SystemEntityProperties {
035:
036: private SystemEntityProperties sep = null;
037: private String prefix = null;
038:
039: private SubSpaceSystemEntityProperties(
040: SystemEntityProperties inSep, String inPrefix) {
041: //
042: this .sep = inSep;
043: this .prefix = inPrefix + "_";
044: }
045:
046: protected String getPrefix() {
047:
048: String outValue = null;
049:
050: if (this .sep instanceof SubSpaceSystemEntityProperties) {
051: SubSpaceSystemEntityProperties sssep = (SubSpaceSystemEntityProperties) this .sep;
052: outValue = sssep.getPrefix() + this .prefix;
053: } else {
054: outValue = this .prefix;
055: }
056:
057: return outValue;
058: }
059:
060: protected SystemEntityProperties getProperties() {
061:
062: SystemEntityProperties outValue = null;
063:
064: if (this .sep instanceof SubSpaceSystemEntityProperties) {
065: SubSpaceSystemEntityProperties sssep = (SubSpaceSystemEntityProperties) this .sep;
066: outValue = sssep.getProperties();
067: } else {
068: outValue = this .sep;
069: }
070:
071: return outValue;
072: }
073:
074: public final static SubSpaceSystemEntityProperties newInstance(
075: SystemEntityProperties inSep, String inPrefix) {
076:
077: return new SubSpaceSystemEntityProperties(inSep, inPrefix);
078: }
079:
080: public int getVersion() {
081: //
082: throw UnexpectedSystemException.unknownState();
083: }
084:
085: //
086: public int getPropertyCount() {
087:
088: int outValue = 0;
089:
090: for (int i = 0; i < getProperties().getPropertyCount(); i++) {
091: if (getProperties().getPropertyName(i).startsWith(
092: getPrefix())) {
093: outValue++;
094: }
095: }
096:
097: return outValue;
098: }
099:
100: //
101: public String getPropertyValue(String inName) {
102: return getProperties().getPropertyValue(getPrefix() + inName);
103: }
104:
105: //
106: public String getPropertyName(int inIndex) {
107:
108: String outValue = null;
109:
110: int currentIndex = 0;
111:
112: for (int i = 0; i < getProperties().getPropertyCount(); i++) {
113: String nextName = getProperties().getPropertyName(i);
114: if (nextName.startsWith(getPrefix())) {
115: if (inIndex == currentIndex) {
116: outValue = nextName.substring(getPrefix().length());
117: break;
118: }
119: //
120: currentIndex++;
121: }
122: }
123:
124: return outValue;
125: }
126:
127: public String getPropertyValue(int inIndex) {
128:
129: String outValue = null;
130:
131: int currentIndex = 0;
132:
133: for (int i = 0; i < getProperties().getPropertyCount(); i++) {
134: String nextName = getProperties().getPropertyName(i);
135: String nextValue = getProperties().getPropertyValue(i);
136: if (nextName.startsWith(getPrefix())) {
137: if (inIndex == currentIndex) {
138: outValue = nextValue;
139: break;
140: }
141: //
142: currentIndex++;
143: }
144: }
145:
146: return outValue;
147: }
148:
149: //
150: public boolean isPropertyPresent(String inName) {
151: return getProperties().isPropertyPresent(getPrefix() + inName);
152: }
153:
154: //
155: public boolean isValidPropertyName(String inName) {
156: return getProperties().isValidPropertyName(inName)
157: && getProperties().isValidPropertyName(
158: getPrefix() + inName);
159: }
160:
161: public boolean isValidPropertyValue(String inValue) {
162: return getProperties().isValidPropertyValue(inValue);
163: }
164:
165: public void createProperty(String inName, String inValue) {
166: getProperties().createProperty(getPrefix() + inName, inValue);
167: }
168:
169: public void updateProperty(String inName, String inValue) {
170: getProperties().updateProperty(getPrefix() + inName, inValue);
171: }
172:
173: public void removeProperty(String inName) {
174: getProperties().removeProperty(getPrefix() + inName);
175: }
176:
177: //
178: public void setDocument(String inDocument) {
179: //
180: this .sep.setDocument(inDocument);
181: }
182:
183: public String getDocument() {
184: //
185: return this .sep.getDocument();
186: }
187:
188: public boolean isValidDocument(String inDocument) {
189: //
190: return this .sep.isValidDocument(inDocument);
191: }
192:
193: //
194: public void initialize(InitializeConceptTagContext inIctc) {
195: //
196: throw UnexpectedSystemException.unknownState();
197: }
198:
199: public void appraise(AppraiseConceptTagContext inCtic) {
200: //
201: throw UnexpectedSystemException.unknownState();
202: }
203:
204: public SystemEntityUpdates getSystemEntityUpdates(
205: SystemEntityUpdatesContext inSeuc) {
206: //
207: throw UnexpectedSystemException.unknownState();
208: }
209:
210: }
|