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.tagging;
009:
010: //base classes
011: import java.util.ArrayList;
012:
013: //project specific classes
014: import org.jfolder.common.UnexpectedSystemException;
015:
016: //other classes
017:
018: abstract class ConceptTagConstraintType {
019:
020: //qualitative
021: private String title = null;
022: private String shortDescription = null;
023: private String longDescription = null;
024: private String icon = null;
025: //private boolean studioVisibleOnlyOnError = false;
026: //
027: private ConceptTagPreferences ctp = null;
028: //
029: //private ConceptTagFlags ctf = null;
030: private ConceptTagFlags validateCtf = null;
031: private ConceptTagFlags reserveCtf = null;
032:
033: protected ConceptTagConstraintType(ConceptTagPreferences inCtp) {
034:
035: //
036: this .ctp = inCtp;
037: //
038: this .validateCtf = new ConceptTagFlags();
039: this .reserveCtf = new ConceptTagFlags();
040: //this.icon = "folder";
041: //this.studioVisibleOnlyOnError = false;
042: //
043: //this.ctf = new ConceptTagFlags(inCtf);
044: }
045:
046: //
047: public void createValidationFlag(String inNs, String inName,
048: Object inVal) {
049: this .validateCtf.createFlag(inNs, inName, inVal);
050: }
051:
052: public void createValidationMainFlag(String inName, Object inVal) {
053: this .validateCtf.createMainFlag(inName, inVal);
054: }
055:
056: //
057: protected void preValidationFlagPreparation(
058: InitializeConceptTagContext inIctc) {
059: //
060: this .reserveCtf.initialize();
061: //
062: ConceptTagFlags ictcCtf = inIctc.getFlags();
063: //
064: ArrayList namespaces = this .validateCtf.getAllNamespaces();
065: for (int i = 0; i < namespaces.size(); i++) {
066: String nextNamespace = (String) namespaces.get(i);
067: ArrayList names = this .validateCtf
068: .getAllNames(nextNamespace);
069: //
070: for (int j = 0; j < names.size(); j++) {
071: String nextName = (String) names.get(j);
072: //
073: if (ictcCtf.isFlagPresent(nextNamespace, nextName)) {
074: this .reserveCtf.createFlag(nextNamespace, nextName,
075: ictcCtf.getFlag(nextNamespace, nextName));
076: //
077: ictcCtf.updateFlag(nextNamespace, nextName,
078: this .validateCtf.getFlag(nextNamespace,
079: nextName));
080: } else {
081: ictcCtf.createFlag(nextNamespace, nextName,
082: this .validateCtf.getFlag(nextNamespace,
083: nextName));
084: }
085: }
086: }
087: }
088:
089: protected void postValidationFlagPreparation(
090: InitializeConceptTagContext inIctc) {
091: //
092: //
093: //
094: ConceptTagFlags ictcCtf = inIctc.getFlags();
095: //
096: ArrayList namespaces = this .validateCtf.getAllNamespaces();
097: for (int i = 0; i < namespaces.size(); i++) {
098: String nextNamespace = (String) namespaces.get(i);
099: ArrayList names = this .validateCtf
100: .getAllNames(nextNamespace);
101: //
102: for (int j = 0; j < names.size(); j++) {
103: String nextName = (String) names.get(j);
104: //
105: if (this .reserveCtf.isFlagPresent(nextNamespace,
106: nextName)) {
107: //this.reserveCtf.createFlag(
108: // nextNamespace, nextName,
109: // ictcCtf.getFlag(nextNamespace, nextName));
110: //
111: ictcCtf.updateFlag(nextNamespace, nextName,
112: this .reserveCtf.getFlag(nextNamespace,
113: nextName));
114: } else {
115: ictcCtf.removeFlag(nextNamespace, nextName);
116: }
117: }
118: }
119: }
120:
121: //
122: protected void setValidationFlags(ConceptTagFlags inCtf) {
123: this .validateCtf = inCtf;
124: }
125:
126: protected ConceptTagFlags getValidationFlags() {
127: return this .validateCtf;
128: }
129:
130: //
131: //protected void setFlags(ConceptTagFlags inCtf) {
132: // this.ctf = inCtf;
133: //}
134: //protected ConceptTagFlags getFlags() {
135: // return this.ctf;
136: //}
137:
138: public ConceptTagPreferences getPreferences() {
139: return this .ctp;
140: }
141:
142: //public boolean isStudioVisibleOnlyOnError() {
143: // return this.studioVisibleOnlyOnError;
144: //}
145:
146: //public void setStudioVisibleOnlyOnError(boolean inVisible) {
147: // this.studioVisibleOnlyOnError = inVisible;
148: //}
149: //
150: public String getTitle() {
151: return this .title;
152: }
153:
154: public String getShortDescription() {
155: return this .shortDescription;
156: }
157:
158: public String getLongDescription() {
159: return this .longDescription;
160: }
161:
162: public String getIcon() {
163: return this .icon;
164: }
165:
166: //
167: public void setTitle(String inTitle) {
168: this .title = inTitle;
169: }
170:
171: public void setShortDescription(String inShortDescription) {
172: this .shortDescription = inShortDescription;
173: }
174:
175: public void setLongDescription(String inLongDescription) {
176: this .longDescription = inLongDescription;
177: }
178:
179: public void setIcon(String inIcon) {
180: this.icon = inIcon;
181: }
182:
183: }
|