0001: /**********************************************************************************
0002: * $URL: https://source.sakaiproject.org/svn/content/tags/sakai_2-4-1/content-tool/tool/src/java/org/sakaiproject/content/tool/ResourcesMetadata.java $
0003: * $Id: ResourcesMetadata.java 20582 2007-01-23 16:59:11Z ian@caret.cam.ac.uk $
0004: ***********************************************************************************
0005: *
0006: * Copyright (c) 2005, 2006 The Sakai Foundation.
0007: *
0008: * Licensed under the Educational Community License, Version 1.0 (the "License");
0009: * you may not use this file except in compliance with the License.
0010: * You may obtain a copy of the License at
0011: *
0012: * http://www.opensource.org/licenses/ecl1.php
0013: *
0014: * Unless required by applicable law or agreed to in writing, software
0015: * distributed under the License is distributed on an "AS IS" BASIS,
0016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0017: * See the License for the specific language governing permissions and
0018: * limitations under the License.
0019: *
0020: **********************************************************************************/package org.sakaiproject.content.tool;
0021:
0022: import java.util.Hashtable;
0023: import java.util.Iterator;
0024: import java.util.List;
0025: import java.util.Map;
0026: import java.util.Vector;
0027: import java.util.regex.Pattern;
0028:
0029: import org.sakaiproject.content.api.ContentHostingHandler;
0030: import org.sakaiproject.content.api.ContentHostingHandlerResolver;
0031: import org.sakaiproject.content.api.ContentHostingService;
0032: import org.sakaiproject.util.ResourceLoader;
0033:
0034: /**
0035: * The class represents metadata properties.
0036: */
0037: public class ResourcesMetadata {
0038: /** Resource bundle using current language locale */
0039: private static ResourceLoader rb = new ResourceLoader("content");
0040:
0041: public static final String WIDGET_STRING = "string";
0042: public static final String WIDGET_TEXTAREA = "textarea";
0043: public static final String WIDGET_BOOLEAN = "boolean";
0044: public static final String WIDGET_INTEGER = "integer";
0045: public static final String WIDGET_DOUBLE = "double";
0046: public static final String WIDGET_DATE = "date";
0047: public static final String WIDGET_TIME = "time";
0048: public static final String WIDGET_DATETIME = "datetime";
0049: public static final String WIDGET_ANYURI = "anyURI";
0050: public static final String WIDGET_ENUM = "enumeration";
0051: public static final String WIDGET_NESTED = "nested";
0052: public static final String WIDGET_WYSIWYG = "wysiwig-editor";
0053:
0054: public static final String XSD_STRING = "string";
0055: public static final String XSD_BOOLEAN = "boolean";
0056: public static final String XSD_INTEGER = "integer";
0057: public static final String XSD_FLOAT = "float";
0058: public static final String XSD_DOUBLE = "double";
0059: public static final String XSD_DATE = "date";
0060: public static final String XSD_TIME = "time";
0061: public static final String XSD_DATETIME = "dateTime";
0062: public static final String XSD_DURATION = "duration";
0063: public static final String XSD_ANYURI = "anyURI";
0064: public static final String XSD_NORMALIZED_STRING = "normalizedString";
0065:
0066: public static final String CLASS_SAKAI_RESOURCE_NAMESPACE = "http://sakaiproject.org/metadata#";
0067: public static final String CLASS_SAKAI_RESOURCE_LOCALNAME = "Resource";
0068: public static final String CLASS_SAKAI_RESOURCE_LABEL = "Resource";
0069:
0070: public static final String NAMESPACE_DC = "http://purl.org/dc/elements/1.1/";
0071: public static final String NAMESPACE_DC_ABBREV = "dc:";
0072: public static final String NAMESPACE_DCTERMS = "http://purl.org/dc/terms/";
0073: public static final String NAMESPACE_DCTERMS_ABBREV = "dcterms:";
0074: public static final String NAMESPACE_XSD = "http://www.w3.org/2001/XMLSchema#";
0075: public static final String NAMESPACE_XSD_ABBREV = "xs:";
0076:
0077: protected static Integer NamespaceNumber = new Integer(0);
0078:
0079: public static final String PROPERTY_NAME_DC_TITLE = "title";
0080: public static final String PROPERTY_LABEL_DC_TITLE = rb
0081: .getString("label.dc_title");
0082: public static final String PROPERTY_DESCRIPTION_DC_TITLE = rb
0083: .getString("descr.dc_title");
0084: public static final String PROPERTY_TYPE_DC_TITLE = NAMESPACE_XSD
0085: + XSD_STRING;
0086: public static final String PROPERTY_WIDGET_DC_TITLE = WIDGET_STRING;
0087:
0088: public static final ResourcesMetadata PROPERTY_DC_TITLE = new ResourcesMetadata(
0089: NAMESPACE_DC, PROPERTY_NAME_DC_TITLE,
0090: PROPERTY_LABEL_DC_TITLE, PROPERTY_DESCRIPTION_DC_TITLE,
0091: PROPERTY_TYPE_DC_TITLE, PROPERTY_WIDGET_DC_TITLE);
0092:
0093: public static final String PROPERTY_NAME_DC_ALTERNATIVE = "alternative";
0094: public static final String PROPERTY_LABEL_DC_ALTERNATIVE = rb
0095: .getString("label.dc_alt");
0096: public static final String PROPERTY_DESCRIPTION_DC_ALTERNATIVE = rb
0097: .getString("descr.dc_alt");
0098: public static final String PROPERTY_TYPE_DC_ALTERNATIVE = NAMESPACE_XSD
0099: + XSD_STRING;
0100: public static final String PROPERTY_WIDGET_DC_ALTERNATIVE = WIDGET_STRING;
0101:
0102: public static final ResourcesMetadata PROPERTY_DC_ALTERNATIVE = new ResourcesMetadata(
0103: NAMESPACE_DC, PROPERTY_NAME_DC_ALTERNATIVE,
0104: PROPERTY_LABEL_DC_ALTERNATIVE,
0105: PROPERTY_DESCRIPTION_DC_ALTERNATIVE,
0106: PROPERTY_TYPE_DC_ALTERNATIVE,
0107: PROPERTY_WIDGET_DC_ALTERNATIVE);
0108:
0109: public static final String PROPERTY_NAME_DC_CREATOR = "creator";
0110: public static final String PROPERTY_LABEL_DC_CREATOR = rb
0111: .getString("label.dc_creator");
0112: public static final String PROPERTY_DESCRIPTION_DC_CREATOR = rb
0113: .getString("descr.dc_creator");
0114: public static final String PROPERTY_TYPE_DC_CREATOR = NAMESPACE_XSD
0115: + XSD_STRING;
0116: public static final String PROPERTY_WIDGET_DC_CREATOR = WIDGET_STRING;
0117:
0118: public static final ResourcesMetadata PROPERTY_DC_CREATOR = new ResourcesMetadata(
0119: NAMESPACE_DC, PROPERTY_NAME_DC_CREATOR,
0120: PROPERTY_LABEL_DC_CREATOR, PROPERTY_DESCRIPTION_DC_CREATOR,
0121: PROPERTY_TYPE_DC_CREATOR, PROPERTY_WIDGET_DC_CREATOR);
0122:
0123: public static final String PROPERTY_NAME_DC_SUBJECT = "subject";
0124: public static final String PROPERTY_LABEL_DC_SUBJECT = rb
0125: .getString("label.dc_subject");
0126: public static final String PROPERTY_DESCRIPTION_DC_SUBJECT = rb
0127: .getString("descr.dc_subject");
0128: public static final String PROPERTY_TYPE_DC_SUBJECT = NAMESPACE_XSD
0129: + XSD_STRING;
0130: public static final String PROPERTY_WIDGET_DC_SUBJECT = WIDGET_TEXTAREA;
0131:
0132: public static final ResourcesMetadata PROPERTY_DC_SUBJECT = new ResourcesMetadata(
0133: NAMESPACE_DC, PROPERTY_NAME_DC_SUBJECT,
0134: PROPERTY_LABEL_DC_SUBJECT, PROPERTY_DESCRIPTION_DC_SUBJECT,
0135: PROPERTY_TYPE_DC_SUBJECT, PROPERTY_WIDGET_DC_SUBJECT);
0136:
0137: public static final String PROPERTY_NAME_DC_DESCRIPTION = "description";
0138: public static final String PROPERTY_LABEL_DC_DESCRIPTION = rb
0139: .getString("label.dc_descr");
0140: public static final String PROPERTY_DESCRIPTION_DC_DESCRIPTION = rb
0141: .getString("descr.dc_descr");
0142: public static final String PROPERTY_TYPE_DC_DESCRIPTION = NAMESPACE_XSD
0143: + XSD_STRING;
0144: public static final String PROPERTY_WIDGET_DC_DESCRIPTION = WIDGET_TEXTAREA;
0145:
0146: public static final ResourcesMetadata PROPERTY_DC_DESCRIPTION = new ResourcesMetadata(
0147: NAMESPACE_DC, PROPERTY_NAME_DC_DESCRIPTION,
0148: PROPERTY_LABEL_DC_DESCRIPTION,
0149: PROPERTY_DESCRIPTION_DC_DESCRIPTION,
0150: PROPERTY_TYPE_DC_DESCRIPTION,
0151: PROPERTY_WIDGET_DC_DESCRIPTION);
0152:
0153: public static final String PROPERTY_NAME_DC_PUBLISHER = "publisher";
0154: public static final String PROPERTY_LABEL_DC_PUBLISHER = rb
0155: .getString("label.dc_publisher");
0156: public static final String PROPERTY_DESCRIPTION_DC_PUBLISHER = rb
0157: .getString("descr.dc_publisher");
0158: public static final String PROPERTY_TYPE_DC_PUBLISHER = NAMESPACE_XSD
0159: + XSD_STRING;
0160: public static final String PROPERTY_WIDGET_DC_PUBLISHER = WIDGET_STRING;
0161:
0162: public static final ResourcesMetadata PROPERTY_DC_PUBLISHER = new ResourcesMetadata(
0163: NAMESPACE_DC, PROPERTY_NAME_DC_PUBLISHER,
0164: PROPERTY_LABEL_DC_PUBLISHER,
0165: PROPERTY_DESCRIPTION_DC_PUBLISHER,
0166: PROPERTY_TYPE_DC_PUBLISHER, PROPERTY_WIDGET_DC_PUBLISHER);
0167:
0168: public static final String PROPERTY_NAME_DC_CONTRIBUTOR = "contributor";
0169: public static final String PROPERTY_LABEL_DC_CONTRIBUTOR = rb
0170: .getString("label.dc_contributor");
0171: public static final String PROPERTY_DESCRIPTION_DC_CONTRIBUTOR = rb
0172: .getString("descr.dc_contributor");
0173: public static final String PROPERTY_TYPE_DC_CONTRIBUTOR = NAMESPACE_XSD
0174: + XSD_STRING;
0175: public static final String PROPERTY_WIDGET_DC_CONTRIBUTOR = WIDGET_TEXTAREA;
0176:
0177: public static final ResourcesMetadata PROPERTY_DC_CONTRIBUTOR = new ResourcesMetadata(
0178: NAMESPACE_DC, PROPERTY_NAME_DC_CONTRIBUTOR,
0179: PROPERTY_LABEL_DC_CONTRIBUTOR,
0180: PROPERTY_DESCRIPTION_DC_CONTRIBUTOR,
0181: PROPERTY_TYPE_DC_CONTRIBUTOR,
0182: PROPERTY_WIDGET_DC_CONTRIBUTOR);
0183:
0184: public static final String PROPERTY_NAME_DC_TYPE = "type";
0185: public static final String PROPERTY_LABEL_DC_TYPE = rb
0186: .getString("label.dc_type");
0187: public static final String PROPERTY_DESCRIPTION_DC_TYPE = rb
0188: .getString("descr.dc_type");
0189: public static final String PROPERTY_TYPE_DC_TYPE = NAMESPACE_XSD
0190: + XSD_STRING;
0191: public static final String PROPERTY_WIDGET_DC_TYPE = WIDGET_STRING;
0192:
0193: public static final ResourcesMetadata PROPERTY_DC_TYPE = new ResourcesMetadata(
0194: NAMESPACE_DC, PROPERTY_NAME_DC_TYPE,
0195: PROPERTY_LABEL_DC_TYPE, PROPERTY_DESCRIPTION_DC_TYPE,
0196: PROPERTY_TYPE_DC_TYPE, PROPERTY_WIDGET_DC_TYPE);
0197:
0198: public static final String PROPERTY_NAME_DC_FORMAT = "format";
0199: public static final String PROPERTY_LABEL_DC_FORMAT = rb
0200: .getString("label.dc_format");
0201: public static final String PROPERTY_DESCRIPTION_DC_FORMAT = rb
0202: .getString("descr.dc_format");
0203: public static final String PROPERTY_TYPE_DC_FORMAT = NAMESPACE_XSD
0204: + XSD_STRING;
0205: public static final String PROPERTY_WIDGET_DC_FORMAT = WIDGET_STRING;
0206:
0207: public static final ResourcesMetadata PROPERTY_DC_FORMAT = new ResourcesMetadata(
0208: NAMESPACE_DC, PROPERTY_NAME_DC_FORMAT,
0209: PROPERTY_LABEL_DC_FORMAT, PROPERTY_DESCRIPTION_DC_FORMAT,
0210: PROPERTY_TYPE_DC_FORMAT, PROPERTY_WIDGET_DC_FORMAT);
0211:
0212: public static final String PROPERTY_NAME_DC_IDENTIFIER = "identifier";
0213: public static final String PROPERTY_LABEL_DC_IDENTIFIER = rb
0214: .getString("label.dc_id");
0215: public static final String PROPERTY_DESCRIPTION_DC_IDENTIFIER = rb
0216: .getString("descr.dc_id");
0217: public static final String PROPERTY_TYPE_DC_IDENTIFIER = NAMESPACE_XSD
0218: + XSD_STRING;
0219: public static final String PROPERTY_WIDGET_DC_IDENTIFIER = WIDGET_STRING; // WIDGET_ANYURI;
0220:
0221: public static final ResourcesMetadata PROPERTY_DC_IDENTIFIER = new ResourcesMetadata(
0222: NAMESPACE_DC, PROPERTY_NAME_DC_IDENTIFIER,
0223: PROPERTY_LABEL_DC_IDENTIFIER,
0224: PROPERTY_DESCRIPTION_DC_IDENTIFIER,
0225: PROPERTY_TYPE_DC_IDENTIFIER, PROPERTY_WIDGET_DC_IDENTIFIER);
0226:
0227: public static final String PROPERTY_NAME_DC_SOURCE = "source";
0228: public static final String PROPERTY_LABEL_DC_SOURCE = rb
0229: .getString("label.dc_source");
0230: public static final String PROPERTY_DESCRIPTION_DC_SOURCE = rb
0231: .getString("descr.dc_source");
0232: public static final String PROPERTY_TYPE_DC_SOURCE = NAMESPACE_XSD
0233: + XSD_STRING;
0234: public static final String PROPERTY_WIDGET_DC_SOURCE = WIDGET_STRING;
0235:
0236: public static final ResourcesMetadata PROPERTY_DC_SOURCE = new ResourcesMetadata(
0237: NAMESPACE_DC, PROPERTY_NAME_DC_SOURCE,
0238: PROPERTY_LABEL_DC_SOURCE, PROPERTY_DESCRIPTION_DC_SOURCE,
0239: PROPERTY_TYPE_DC_SOURCE, PROPERTY_WIDGET_DC_SOURCE);
0240:
0241: public static final String PROPERTY_NAME_DC_LANGUAGE = "language";
0242: public static final String PROPERTY_LABEL_DC_LANGUAGE = rb
0243: .getString("label.dc_lang");
0244: public static final String PROPERTY_DESCRIPTION_DC_LANGUAGE = rb
0245: .getString("descr.dc_lang");
0246: public static final String PROPERTY_TYPE_DC_LANGUAGE = NAMESPACE_XSD
0247: + XSD_STRING;
0248: public static final String PROPERTY_WIDGET_DC_LANGUAGE = WIDGET_STRING;
0249:
0250: public static final ResourcesMetadata PROPERTY_DC_LANGUAGE = new ResourcesMetadata(
0251: NAMESPACE_DC, PROPERTY_NAME_DC_LANGUAGE,
0252: PROPERTY_LABEL_DC_LANGUAGE,
0253: PROPERTY_DESCRIPTION_DC_LANGUAGE,
0254: PROPERTY_TYPE_DC_LANGUAGE, PROPERTY_WIDGET_DC_LANGUAGE);
0255:
0256: public static final String PROPERTY_NAME_DC_COVERAGE = "coverage";
0257: public static final String PROPERTY_LABEL_DC_COVERAGE = rb
0258: .getString("label.dc_coverage");
0259: public static final String PROPERTY_DESCRIPTION_DC_COVERAGE = rb
0260: .getString("descr.dc_coverage");
0261: public static final String PROPERTY_TYPE_DC_COVERAGE = NAMESPACE_XSD
0262: + XSD_STRING;
0263: public static final String PROPERTY_WIDGET_DC_COVERAGE = WIDGET_STRING;
0264:
0265: public static final ResourcesMetadata PROPERTY_DC_COVERAGE = new ResourcesMetadata(
0266: NAMESPACE_DC, PROPERTY_NAME_DC_COVERAGE,
0267: PROPERTY_LABEL_DC_COVERAGE,
0268: PROPERTY_DESCRIPTION_DC_COVERAGE,
0269: PROPERTY_TYPE_DC_COVERAGE, PROPERTY_WIDGET_DC_COVERAGE);
0270:
0271: public static final String PROPERTY_NAME_DC_RIGHTS = "rights";
0272: public static final String PROPERTY_LABEL_DC_RIGHTS = rb
0273: .getString("label.dc_rights");
0274: public static final String PROPERTY_DESCRIPTION_DC_RIGHTS = rb
0275: .getString("descr.dc_rights");
0276: public static final String PROPERTY_TYPE_DC_RIGHTS = NAMESPACE_XSD
0277: + XSD_STRING;
0278: public static final String PROPERTY_WIDGET_DC_RIGHTS = WIDGET_STRING;
0279:
0280: public static final ResourcesMetadata PROPERTY_DC_RIGHTS = new ResourcesMetadata(
0281: NAMESPACE_DC, PROPERTY_NAME_DC_RIGHTS,
0282: PROPERTY_LABEL_DC_RIGHTS, PROPERTY_DESCRIPTION_DC_RIGHTS,
0283: PROPERTY_TYPE_DC_RIGHTS, PROPERTY_WIDGET_DC_RIGHTS);
0284:
0285: public static final String PROPERTY_NAME_DC_AUDIENCE = "audience";
0286: public static final String PROPERTY_LABEL_DC_AUDIENCE = rb
0287: .getString("label.dc_audience");
0288: public static final String PROPERTY_DESCRIPTION_DC_AUDIENCE = rb
0289: .getString("descr.dc_audience");
0290: public static final String PROPERTY_TYPE_DC_AUDIENCE = NAMESPACE_XSD
0291: + XSD_STRING;
0292: public static final String PROPERTY_WIDGET_DC_AUDIENCE = WIDGET_STRING;
0293:
0294: public static final ResourcesMetadata PROPERTY_DC_AUDIENCE = new ResourcesMetadata(
0295: NAMESPACE_DCTERMS, PROPERTY_NAME_DC_AUDIENCE,
0296: PROPERTY_LABEL_DC_AUDIENCE,
0297: PROPERTY_DESCRIPTION_DC_AUDIENCE,
0298: PROPERTY_TYPE_DC_AUDIENCE, PROPERTY_WIDGET_DC_AUDIENCE);
0299:
0300: public static final String PROPERTY_NAME_DC_TABLEOFCONTENTS = "tableOfContents";
0301: public static final String PROPERTY_LABEL_DC_TABLEOFCONTENTS = rb
0302: .getString("label.dc_toc");
0303: public static final String PROPERTY_DESCRIPTION_DC_TABLEOFCONTENTS = rb
0304: .getString("descr.dc_toc");
0305: public static final String PROPERTY_TYPE_DC_TABLEOFCONTENTS = NAMESPACE_XSD
0306: + XSD_STRING;
0307: public static final String PROPERTY_WIDGET_DC_TABLEOFCONTENTS = WIDGET_TEXTAREA;
0308:
0309: public static final ResourcesMetadata PROPERTY_DC_TABLEOFCONTENTS = new ResourcesMetadata(
0310: NAMESPACE_DCTERMS, PROPERTY_NAME_DC_TABLEOFCONTENTS,
0311: PROPERTY_LABEL_DC_TABLEOFCONTENTS,
0312: PROPERTY_DESCRIPTION_DC_TABLEOFCONTENTS,
0313: PROPERTY_TYPE_DC_TABLEOFCONTENTS,
0314: PROPERTY_WIDGET_DC_TABLEOFCONTENTS);
0315:
0316: public static final String PROPERTY_NAME_DC_ABSTRACT = "abstract";
0317: public static final String PROPERTY_LABEL_DC_ABSTRACT = rb
0318: .getString("label.dc_abstract");
0319: public static final String PROPERTY_DESCRIPTION_DC_ABSTRACT = rb
0320: .getString("descr.dc_abstract");
0321: public static final String PROPERTY_TYPE_DC_ABSTRACT = NAMESPACE_XSD
0322: + XSD_STRING;
0323: public static final String PROPERTY_WIDGET_DC_ABSTRACT = WIDGET_TEXTAREA;
0324:
0325: public static final ResourcesMetadata PROPERTY_DC_ABSTRACT = new ResourcesMetadata(
0326: NAMESPACE_DCTERMS, PROPERTY_NAME_DC_ABSTRACT,
0327: PROPERTY_LABEL_DC_ABSTRACT,
0328: PROPERTY_DESCRIPTION_DC_ABSTRACT,
0329: PROPERTY_TYPE_DC_ABSTRACT, PROPERTY_WIDGET_DC_ABSTRACT);
0330:
0331: public static final String PROPERTY_NAME_DC_CREATED = "created";
0332: public static final String PROPERTY_LABEL_DC_CREATED = rb
0333: .getString("label.dc_created");
0334: public static final String PROPERTY_DESCRIPTION_DC_CREATED = rb
0335: .getString("descr.dc_created");
0336: public static final String PROPERTY_TYPE_DC_CREATED = NAMESPACE_XSD
0337: + XSD_DATE;
0338: public static final String PROPERTY_WIDGET_DC_CREATED = WIDGET_DATE;
0339:
0340: public static final ResourcesMetadata PROPERTY_DC_CREATED = new ResourcesMetadata(
0341: NAMESPACE_DCTERMS, PROPERTY_NAME_DC_CREATED,
0342: PROPERTY_LABEL_DC_CREATED, PROPERTY_DESCRIPTION_DC_CREATED,
0343: PROPERTY_TYPE_DC_CREATED, PROPERTY_WIDGET_DC_CREATED);
0344:
0345: public static final String PROPERTY_NAME_DC_ISSUED = "issued";
0346: public static final String PROPERTY_LABEL_DC_ISSUED = rb
0347: .getString("label.dc_issued");
0348: public static final String PROPERTY_DESCRIPTION_DC_ISSUED = rb
0349: .getString("descr.dc_issued");
0350: public static final String PROPERTY_TYPE_DC_ISSUED = NAMESPACE_XSD
0351: + XSD_DATE;
0352: public static final String PROPERTY_WIDGET_DC_ISSUED = WIDGET_DATE;
0353:
0354: public static final ResourcesMetadata PROPERTY_DC_ISSUED = new ResourcesMetadata(
0355: NAMESPACE_DCTERMS, PROPERTY_NAME_DC_ISSUED,
0356: PROPERTY_LABEL_DC_ISSUED, PROPERTY_DESCRIPTION_DC_ISSUED,
0357: PROPERTY_TYPE_DC_ISSUED, PROPERTY_WIDGET_DC_ISSUED);
0358:
0359: public static final String PROPERTY_NAME_DC_MODIFIED = "modified";
0360: public static final String PROPERTY_LABEL_DC_MODIFIED = rb
0361: .getString("label.dc_modified");
0362: public static final String PROPERTY_DESCRIPTION_DC_MODIFIED = rb
0363: .getString("descr.dc_modified");
0364: public static final String PROPERTY_TYPE_DC_MODIFIED = NAMESPACE_XSD
0365: + XSD_DATE;
0366: public static final String PROPERTY_WIDGET_DC_MODIFIED = WIDGET_DATE;
0367:
0368: public static final ResourcesMetadata PROPERTY_DC_MODIFIED = new ResourcesMetadata(
0369: NAMESPACE_DCTERMS, PROPERTY_NAME_DC_MODIFIED,
0370: PROPERTY_LABEL_DC_MODIFIED,
0371: PROPERTY_DESCRIPTION_DC_MODIFIED,
0372: PROPERTY_TYPE_DC_MODIFIED, PROPERTY_WIDGET_DC_MODIFIED);
0373:
0374: public static final String PROPERTY_NAME_DC_EDULEVEL = "educationLevel";
0375: public static final String PROPERTY_LABEL_DC_EDULEVEL = rb
0376: .getString("label.dc_edlevel");
0377: public static final String PROPERTY_DESCRIPTION_DC_EDULEVEL = rb
0378: .getString("descr.dc_edlevel");
0379: public static final String PROPERTY_TYPE_DC_EDULEVEL = NAMESPACE_XSD
0380: + XSD_STRING;
0381: public static final String PROPERTY_WIDGET_DC_EDULEVEL = WIDGET_TEXTAREA;
0382:
0383: public static final ResourcesMetadata PROPERTY_DC_EDULEVEL = new ResourcesMetadata(
0384: NAMESPACE_DCTERMS, PROPERTY_NAME_DC_EDULEVEL,
0385: PROPERTY_LABEL_DC_EDULEVEL,
0386: PROPERTY_DESCRIPTION_DC_EDULEVEL,
0387: PROPERTY_TYPE_DC_EDULEVEL, PROPERTY_WIDGET_DC_EDULEVEL);
0388:
0389: /* File System mount points */
0390: public static final String PROPERTY_NAME_FSMOUNT_NAMESPACE = ContentHostingHandlerResolver.CHH_BEAN_NAME
0391: .split(":")[0];
0392: public static final String PROPERTY_NAME_FSMOUNT_ACTIVE = ContentHostingHandlerResolver.CHH_BEAN_NAME
0393: .split(":")[1];
0394: public static final String PROPERTY_LABEL_FSMOUNT_ACTIVE = rb
0395: .getString("label.fsmount_active");
0396: public static final String PROPERTY_DESCRIPTION_FSMOUNT_ACTIVE = rb
0397: .getString("descr.fsmount_active");
0398: // TYPE should be a BOOLEAN but that does not appear to be implemented -- miserable.
0399: // Instead, we store a string and ask users to type "YES" or "NO". Yes, this sucks.
0400: public static final String PROPERTY_TYPE_FSMOUNT_ACTIVE = NAMESPACE_XSD
0401: + XSD_STRING;
0402: public static final String PROPERTY_WIDGET_FSMOUNT_ACTIVE = WIDGET_STRING;
0403:
0404: public static final ResourcesMetadata PROPERTY_FSMOUNT_ACTIVE = new ResourcesMetadata(
0405: PROPERTY_NAME_FSMOUNT_NAMESPACE + ":",
0406: PROPERTY_NAME_FSMOUNT_ACTIVE,
0407: PROPERTY_LABEL_FSMOUNT_ACTIVE,
0408: PROPERTY_DESCRIPTION_FSMOUNT_ACTIVE,
0409: PROPERTY_TYPE_FSMOUNT_ACTIVE,
0410: PROPERTY_WIDGET_FSMOUNT_ACTIVE);
0411:
0412: public static final ResourcesMetadata PROPERTY_DC_BOOLEAN = new ResourcesMetadata(
0413: NAMESPACE_XSD, XSD_BOOLEAN, WIDGET_BOOLEAN, "Test "
0414: + WIDGET_BOOLEAN, NAMESPACE_XSD + XSD_BOOLEAN,
0415: WIDGET_BOOLEAN);
0416:
0417: public static final ResourcesMetadata PROPERTY_DC_DATE = new ResourcesMetadata(
0418: NAMESPACE_XSD, XSD_DATE, WIDGET_DATE,
0419: "Test " + WIDGET_DATE, NAMESPACE_XSD + XSD_DATE,
0420: WIDGET_DATE);
0421:
0422: public static final ResourcesMetadata PROPERTY_DC_TIME = new ResourcesMetadata(
0423: NAMESPACE_XSD, XSD_TIME, WIDGET_TIME,
0424: "Test " + WIDGET_TIME, NAMESPACE_XSD + XSD_TIME,
0425: WIDGET_TIME);
0426:
0427: public static final ResourcesMetadata PROPERTY_DC_DATETIME = new ResourcesMetadata(
0428: NAMESPACE_XSD, XSD_DATETIME, WIDGET_DATETIME, "Test "
0429: + WIDGET_DATETIME, NAMESPACE_XSD + XSD_DATETIME,
0430: WIDGET_DATETIME);
0431:
0432: public static final ResourcesMetadata PROPERTY_DC_INTEGER = new ResourcesMetadata(
0433: NAMESPACE_XSD, XSD_INTEGER, WIDGET_INTEGER, "Test "
0434: + WIDGET_INTEGER, NAMESPACE_XSD + XSD_INTEGER,
0435: WIDGET_INTEGER);
0436:
0437: public static final ResourcesMetadata PROPERTY_DC_DOUBLE = new ResourcesMetadata(
0438: NAMESPACE_XSD, XSD_DOUBLE, WIDGET_DOUBLE, "Test "
0439: + WIDGET_DOUBLE, NAMESPACE_XSD + XSD_DOUBLE,
0440: WIDGET_DOUBLE);
0441:
0442: public static final ResourcesMetadata PROPERTY_DC_ANYURI = new ResourcesMetadata(
0443: NAMESPACE_XSD, XSD_ANYURI, WIDGET_ANYURI, "Test "
0444: + WIDGET_ANYURI, NAMESPACE_XSD + XSD_ANYURI,
0445: WIDGET_ANYURI);
0446:
0447: /*
0448: public static final String PROPERTY_NAME_DC_ = "";
0449: public static final String PROPERTY_LABEL_DC_ = "";
0450: public static final String PROPERTY_DESCRIPTION_DC_ =
0451: "";
0452: public static final String PROPERTY_TYPE_DC_ = XSD_STRING;
0453: public static final String PROPERTY_WIDGET_DC_ = WIDGET_STRING;
0454:
0455: public static final ResourcesMetadata PROPERTY_DC_
0456: = new ResourcesMetadata(
0457: PROPERTY_NAME_DC_,
0458: PROPERTY_LABEL_DC_,
0459: PROPERTY_DESCRIPTION_DC_,
0460: PROPERTY_TYPE_DC_,
0461: PROPERTY_WIDGET_DC_
0462: );
0463:
0464: */
0465:
0466: public static final String[] DublinCore = { PROPERTY_NAME_DC_TITLE,
0467: PROPERTY_NAME_DC_ALTERNATIVE, PROPERTY_NAME_DC_CREATOR,
0468: PROPERTY_NAME_DC_SUBJECT, PROPERTY_NAME_DC_DESCRIPTION,
0469: PROPERTY_NAME_DC_TABLEOFCONTENTS,
0470: PROPERTY_NAME_DC_ABSTRACT, PROPERTY_NAME_DC_PUBLISHER,
0471: PROPERTY_NAME_DC_CONTRIBUTOR, PROPERTY_NAME_DC_TYPE,
0472: PROPERTY_NAME_DC_FORMAT, PROPERTY_NAME_DC_CREATED,
0473: PROPERTY_NAME_DC_ISSUED, PROPERTY_NAME_DC_MODIFIED,
0474: PROPERTY_NAME_DC_IDENTIFIER, PROPERTY_NAME_DC_SOURCE,
0475: PROPERTY_NAME_DC_LANGUAGE, PROPERTY_NAME_DC_COVERAGE,
0476: PROPERTY_NAME_DC_RIGHTS, PROPERTY_NAME_DC_AUDIENCE,
0477: PROPERTY_NAME_DC_EDULEVEL };
0478:
0479: public static final ResourcesMetadata[] DEFINED_PROPERTIES = {
0480: PROPERTY_DC_TITLE, PROPERTY_DC_ALTERNATIVE,
0481: PROPERTY_DC_CREATOR, PROPERTY_DC_SUBJECT,
0482: PROPERTY_DC_DESCRIPTION, PROPERTY_DC_TABLEOFCONTENTS,
0483: PROPERTY_DC_ABSTRACT, PROPERTY_DC_PUBLISHER,
0484: PROPERTY_DC_CONTRIBUTOR, PROPERTY_DC_TYPE,
0485: PROPERTY_DC_FORMAT, PROPERTY_DC_CREATED,
0486: PROPERTY_DC_ISSUED, PROPERTY_DC_MODIFIED,
0487: PROPERTY_DC_IDENTIFIER, PROPERTY_DC_SOURCE,
0488: PROPERTY_DC_LANGUAGE, PROPERTY_DC_COVERAGE,
0489: PROPERTY_DC_RIGHTS, PROPERTY_DC_AUDIENCE,
0490: PROPERTY_DC_EDULEVEL, PROPERTY_DC_ANYURI,
0491: PROPERTY_DC_DOUBLE, PROPERTY_DC_DATETIME, PROPERTY_DC_TIME,
0492: PROPERTY_DC_DATE, PROPERTY_DC_BOOLEAN, PROPERTY_DC_INTEGER
0493:
0494: };
0495:
0496: /**
0497: * The character(s) used to delimite parts of the Dotted Name of a StructuredArtifact property.
0498: */
0499: public static final String DOT = ".";
0500:
0501: /**
0502: * A regular expression that will match DOT in an expression.
0503: */
0504: private static final String DOT_REGEX = "\\.";
0505:
0506: /** The default size of the text-input widget for strings */
0507: public static final int DEFAULT_LENGTH = 50;
0508:
0509: public static ResourcesMetadata getProperty(String name) {
0510: ResourcesMetadata rv = null;
0511: if (name != null) {
0512: boolean found = false;
0513: for (int k = 0; !found && k < DEFINED_PROPERTIES.length; k++) {
0514: if (DEFINED_PROPERTIES[k].getFullname()
0515: .equalsIgnoreCase(name)
0516: || DEFINED_PROPERTIES[k].getShortname()
0517: .equalsIgnoreCase(name)) {
0518: rv = DEFINED_PROPERTIES[k];
0519: found = true;
0520: }
0521: }
0522: }
0523: return rv;
0524: }
0525:
0526: public static ResourcesMetadata[] getProperties(String[] names) {
0527: List results = new Vector();
0528: for (int i = 0; i < names.length; i++) {
0529: if (names[i] == null) {
0530: continue;
0531: }
0532: boolean found = false;
0533: for (int k = 0; !found && k < DEFINED_PROPERTIES.length; k++) {
0534: if (DEFINED_PROPERTIES[k].getFullname()
0535: .equalsIgnoreCase(names[i])) {
0536: results.add(DEFINED_PROPERTIES[k]);
0537: found = true;
0538: }
0539: }
0540: }
0541:
0542: ResourcesMetadata[] rv = new ResourcesMetadata[results.size()];
0543:
0544: for (int j = 0; j < results.size(); j++) {
0545: rv[j] = (ResourcesMetadata) results.get(j);
0546: }
0547:
0548: return rv;
0549: }
0550:
0551: /**
0552: * The string representation of the localname for the metadata property
0553: */
0554: protected String m_localname;
0555:
0556: /**
0557: * The string representation of the namespace for the metadata property
0558: */
0559: protected String m_namespace;
0560:
0561: /**
0562: * The parts of the name of a nested structured object.
0563: */
0564: protected List m_dottedparts;
0565:
0566: /**
0567: * A string that can be used to refer to the metadata property
0568: */
0569: protected String m_label;
0570:
0571: /**
0572: * An explanation of the metadata property, including the nature of the legal values
0573: */
0574: protected String m_description;
0575:
0576: /**
0577: * The datatype of legal values for the metadata property
0578: * (usually a URI ref for an XML Schema Datatype)
0579: */
0580: protected String m_datatype;
0581:
0582: /**
0583: * The default editor widget for the metadata property
0584: */
0585: protected String m_widget;
0586:
0587: protected int m_minCardinality;
0588: protected int m_maxCardinality;
0589: protected int m_currentCount;
0590: protected List m_currentValues;
0591: protected int m_length;
0592: protected List m_enumeration;
0593: protected List m_nested;
0594: protected List m_nestedinstances;
0595: protected List m_instances;
0596: protected ResourcesMetadata m_container;
0597: protected ResourcesMetadata m_parent;
0598: protected Object m_minValue;
0599: protected Object m_maxValue;
0600: protected boolean m_minInclusive;
0601: protected boolean m_maxInclusive;
0602: protected Pattern m_pattern;
0603: protected int m_depth;
0604:
0605: /**
0606: * Constructor.
0607: * @param name The string representation of the URI for the metadata property
0608: * @param label A string that can be used to refer to the metadata property
0609: * @param description An explanation of the metadata property, describing the valid values
0610: * @param datatype The datatype of legal values for the metadata property
0611: * (usually a URI ref for an XML Schema Datatype)
0612: * @param widget The default editor widget for the metadata property
0613: */
0614: public ResourcesMetadata(String namespace, String localname,
0615: String label, String description, String datatype,
0616: String widget) {
0617: m_datatype = datatype;
0618: m_description = description;
0619: m_label = label;
0620: m_namespace = namespace;
0621: m_localname = localname;
0622: m_widget = widget;
0623: m_minCardinality = 1;
0624: m_maxCardinality = 1;
0625: m_currentCount = 1;
0626: m_enumeration = null;
0627: m_currentValues = new Vector();
0628: m_nested = new Vector();
0629: m_pattern = Pattern.compile(".*");
0630: m_minInclusive = true;
0631: m_maxInclusive = true;
0632: m_depth = 0;
0633: m_dottedparts = new Vector();
0634: m_nestedinstances = new Vector();
0635: m_instances = new Vector();
0636: m_parent = null;
0637: m_container = null;
0638: m_length = DEFAULT_LENGTH;
0639:
0640: }
0641:
0642: /**
0643: * @param prop
0644: */
0645: public ResourcesMetadata(ResourcesMetadata other) {
0646: m_datatype = other.m_datatype;
0647: m_description = other.m_description;
0648: m_label = other.m_label;
0649: m_namespace = other.m_namespace;
0650: m_localname = other.m_localname;
0651: m_widget = other.m_widget;
0652: m_minCardinality = other.m_minCardinality;
0653: m_maxCardinality = other.m_maxCardinality;
0654: m_currentCount = other.m_currentCount;
0655: if (other.m_enumeration == null) {
0656: m_enumeration = null;
0657: } else {
0658: m_enumeration = new Vector(other.m_enumeration);
0659: }
0660: m_currentValues = new Vector();
0661: m_pattern = other.m_pattern;
0662: m_minInclusive = other.m_minInclusive;
0663: m_maxInclusive = other.m_maxInclusive;
0664: m_depth = other.m_depth;
0665: m_dottedparts = new Vector(other.m_dottedparts);
0666: m_nestedinstances = new Vector();
0667: m_instances = new Vector();
0668: m_nested = new Vector();
0669: Iterator it = other.m_nested.iterator();
0670: while (it.hasNext()) {
0671: ResourcesMetadata child = (ResourcesMetadata) it.next();
0672: this .m_nested.add(new ResourcesMetadata(child));
0673: }
0674: m_container = other.m_container;
0675: m_length = other.m_length;
0676:
0677: }
0678:
0679: /**
0680: * @return The datatype of legal values for the metadata property (usually a URI ref for an XML Schema Datatype)
0681: */
0682: public String getDatatype() {
0683: return m_datatype;
0684: }
0685:
0686: /**
0687: * @return An explanation of the metadata property describing the valid values
0688: */
0689: public String getDescription() {
0690: return m_description;
0691: }
0692:
0693: /**
0694: * @return
0695: */
0696: public String getLabel() {
0697: return m_label;
0698: }
0699:
0700: /**
0701: * @return The string representation of the URI for the metadata property
0702: */
0703: public String getLocalname() {
0704: return m_localname;
0705: }
0706:
0707: /**
0708: * @return The string representation of the full namespace for the metadata property
0709: */
0710: public String getNamespace() {
0711: return m_namespace;
0712: }
0713:
0714: /**
0715: * @return The abbreviated version of the namespace (including delimiter)
0716: */
0717: public String getNamespaceAbbrev() {
0718: return getNamespaceAbbrev(m_namespace);
0719: }
0720:
0721: /**
0722: * @return The string representation of the URI for the metadata property
0723: */
0724: public String getFullname() {
0725: return m_namespace + m_localname;
0726: }
0727:
0728: /**
0729: * @return The string representation of the URI for the metadata property
0730: */
0731: public String getShortname() {
0732: String abbrev = getNamespaceAbbrev(m_namespace);
0733: if (abbrev == null) {
0734: abbrev = m_namespace;
0735: }
0736: return abbrev + m_localname;
0737: }
0738:
0739: /**
0740: * @return The default editor widget for the metadata property
0741: */
0742: public String getWidget() {
0743: return m_widget;
0744: }
0745:
0746: /**
0747: * @param datatype The datatype of legal values for the metadata property (usually a URI ref for an XML Schema Datatype)
0748: */
0749: public void setDatatype(String datatype) {
0750: m_datatype = datatype;
0751: }
0752:
0753: /**
0754: * @param description An explanation of the metadata property describing the valid values
0755: */
0756: public void setDescription(String description) {
0757: m_description = description;
0758: }
0759:
0760: /**
0761: * @param label A string that can be used to refer to the metadata property
0762: */
0763: public void setLabel(String label) {
0764: m_label = label;
0765: }
0766:
0767: /**
0768: * @param name The string representation of the namespace for the metadata property
0769: */
0770: public void setNamespace(String namespace) {
0771: m_namespace = namespace;
0772: }
0773:
0774: /**
0775: * @param name The string representation of the URI for the metadata property
0776: */
0777: public void setLocalname(String localname) {
0778: m_localname = localname;
0779: }
0780:
0781: /**
0782: * @param widget The default editor widget for the metadata property
0783: */
0784: public void setWidget(String widget) {
0785: m_widget = widget;
0786: }
0787:
0788: public void setContainer(ResourcesMetadata container) {
0789: this .m_container = container;
0790: }
0791:
0792: public ResourcesMetadata getContainer() {
0793: return this .m_container;
0794: }
0795:
0796: protected static Map m_ns2abbrev;
0797: protected static Map m_abbrev2ns;
0798:
0799: protected String m_id;
0800:
0801: /**
0802: * @param namespace The string representation of the namespace for the metadata property
0803: * @param abbrev The abbreviated version of the namespace (including delimiter)
0804: */
0805: public static void setNamespaceAbbrev(String namespace,
0806: String abbrev) {
0807: if (m_ns2abbrev == null || m_abbrev2ns == null) {
0808: initNamespaceMaps();
0809: }
0810:
0811: // what if namespace already defined mapping to a different abbrev?
0812: // new abbrev will be used instead but old abbrev will still map to namespace
0813:
0814: m_abbrev2ns.put(abbrev, namespace);
0815: m_ns2abbrev.put(namespace, abbrev);
0816: }
0817:
0818: /**
0819: * @param namespace The string representation of the namespace for a metadata property
0820: * @return The abbreviated version of the namespace identifier (including delimiter)
0821: */
0822: public static String getNamespaceAbbrev(String namespace) {
0823: String abbrev = null;
0824: if (m_ns2abbrev == null) {
0825: initNamespaceMaps();
0826: }
0827: abbrev = (String) m_ns2abbrev.get(namespace);
0828: if (abbrev == null) {
0829: abbrev = assignAbbrev(namespace);
0830: }
0831: return abbrev;
0832: }
0833:
0834: /**
0835: * @param abbrev The abbreviated version of the namespace identifier (including delimiter)
0836: * @return The string representation of the full name of the namespace
0837: */
0838: public static String getNamespace(String abbrev) {
0839: String namespace = null;
0840: if (m_abbrev2ns == null) {
0841: initNamespaceMaps();
0842: }
0843: namespace = (String) m_abbrev2ns.get(abbrev);
0844: return namespace;
0845: }
0846:
0847: /**
0848: * Make sure that maps are defined and default values for Dublin Core
0849: * and XMLSchema Datatypes are included
0850: */
0851: protected static void initNamespaceMaps() {
0852: if (m_ns2abbrev == null) {
0853: m_ns2abbrev = new Hashtable();
0854: }
0855: if (m_abbrev2ns == null) {
0856: m_abbrev2ns = new Hashtable();
0857: }
0858: setNamespaceAbbrev(NAMESPACE_DC, NAMESPACE_DC_ABBREV);
0859: setNamespaceAbbrev(NAMESPACE_DCTERMS, NAMESPACE_DCTERMS_ABBREV);
0860: setNamespaceAbbrev(NAMESPACE_XSD, NAMESPACE_XSD_ABBREV);
0861: }
0862:
0863: protected static String assignAbbrev(String namespace) {
0864: String abbrev = "error";
0865: synchronized (NamespaceNumber) {
0866: abbrev = "s" + NamespaceNumber;
0867: NamespaceNumber = new Integer(
0868: NamespaceNumber.byteValue() + 1);
0869: }
0870: setNamespaceAbbrev(namespace, abbrev);
0871: return abbrev;
0872: }
0873:
0874: /**
0875: * @return Returns the currentCount.
0876: */
0877: public int getCurrentCount() {
0878: return this .m_currentCount;
0879:
0880: }
0881:
0882: /**
0883: * @return Returns the currentCount.
0884: */
0885: public Integer getCount() {
0886: return new Integer(this .getCurrentCount());
0887: }
0888:
0889: public void setValue(String name, Object value) {
0890: if (name.startsWith(this .getDottedname())) {
0891: String localname = name.substring(name.length());
0892: if (localname == null || localname.equals("")) {
0893: if (this .m_currentValues == null) {
0894: this .m_currentValues = new Vector();
0895: }
0896:
0897: if (this .m_currentValues.size() > 0) {
0898: this .m_currentValues.set(0, value);
0899: } else {
0900: this .m_currentValues.add(0, value);
0901: }
0902: } else {
0903: String[] parts = localname.split(DOT_REGEX);
0904: String target = parts[0];
0905: boolean found = false;
0906: Iterator it = getNested().iterator();
0907: ResourcesMetadata prop = null;
0908: while (!found && it.hasNext()) {
0909: prop = (ResourcesMetadata) it.next();
0910: if (prop.getLocalname().equals(target)) {
0911: found = true;
0912: }
0913: }
0914:
0915: if (found) {
0916: prop.setValue(name, value);
0917: }
0918: }
0919: }
0920: }
0921:
0922: /**
0923: * @return
0924: */
0925: public List getValues() {
0926: return m_currentValues;
0927: }
0928:
0929: /**
0930: * @param index
0931: * @return
0932: */
0933: public Object getValue(int index) {
0934: Object rv = null;
0935: try {
0936: rv = m_currentValues.get(index);
0937: } catch (ArrayIndexOutOfBoundsException e) {
0938: // return null
0939: }
0940: return rv;
0941: }
0942:
0943: /**
0944: * @return
0945: */
0946: public Object getValue() {
0947: return getValue(0);
0948: }
0949:
0950: public List getInstanceValues() {
0951: List values = new Vector();
0952: values.addAll(this .m_currentValues);
0953: if (this .m_instances == null) {
0954: this .m_instances = new Vector();
0955: }
0956: Iterator it = this .m_instances.iterator();
0957: while (it.hasNext()) {
0958: ResourcesMetadata instance = (ResourcesMetadata) it.next();
0959: values.addAll(instance.getValues());
0960: }
0961: return values;
0962: }
0963:
0964: /**
0965: * @param index
0966: * @param value
0967: */
0968: public void setValue(int index, Object value) {
0969: try {
0970: m_currentValues.set(index, value);
0971: } catch (ArrayIndexOutOfBoundsException e) {
0972: m_currentValues.add(value);
0973: }
0974: }
0975:
0976: /**
0977: * @param currentCount The currentCount to set.
0978: */
0979: public void setCurrentCount(int currentCount) {
0980: m_currentCount = currentCount;
0981: if (m_parent != null) {
0982: m_parent.setCurrentCount(currentCount);
0983: }
0984: if (this .m_instances != null) {
0985: Iterator it = this .m_instances.iterator();
0986: while (it.hasNext()) {
0987: ResourcesMetadata instance = (ResourcesMetadata) it
0988: .next();
0989: instance.m_currentCount = currentCount;
0990: }
0991: }
0992: }
0993:
0994: /**
0995: * @return Returns the maxCardinality.
0996: */
0997: public int getMaxCardinality() {
0998: return m_maxCardinality;
0999: }
1000:
1001: /**
1002: * @param maxCardinality The maxCardinality to set.
1003: */
1004: public void setMaxCardinality(int maxCardinality) {
1005: m_maxCardinality = maxCardinality;
1006: }
1007:
1008: /**
1009: * @return Returns the minCardinality.
1010: */
1011: public int getMinCardinality() {
1012: return m_minCardinality;
1013: }
1014:
1015: /**
1016: * @param minCardinality The minCardinality to set.
1017: */
1018: public void setMinCardinality(int minCardinality) {
1019: m_minCardinality = minCardinality;
1020: }
1021:
1022: /**
1023: * increments the currentCount if it is less than maxCardinality.
1024: */
1025: public void incrementCount() {
1026: if (this .getCurrentCount() < m_maxCardinality) {
1027: this .setCurrentCount(this .m_currentCount + 1);
1028: }
1029:
1030: } // incrementCount
1031:
1032: /**
1033: * @return true if additional instances of the field can be added, false otherwise.
1034: */
1035: public boolean canAddInstances() {
1036: return this .getCurrentCount() < m_maxCardinality;
1037:
1038: }
1039:
1040: /**
1041: * Access the desired size of a text input field.
1042: * @return Returns the length, which represents the size of a text input field.
1043: */
1044: public int getLength() {
1045: return m_length;
1046:
1047: }
1048:
1049: /**
1050: * Set the the size of a text input field.
1051: * @param length The length to set.
1052: */
1053: public void setLength(int length) {
1054: m_length = length;
1055: }
1056:
1057: /**
1058: * @return Returns the enumeration.
1059: */
1060: public List getEnumeration() {
1061: List rv;
1062: if (m_enumeration == null) {
1063: rv = new Vector();
1064: } else {
1065: rv = new Vector(m_enumeration);
1066: }
1067: return rv;
1068: }
1069:
1070: /**
1071: * @param enumeration The enumeration to set.
1072: */
1073: public void setEnumeration(List enumeration) {
1074: m_enumeration = new Vector(enumeration);
1075: }
1076:
1077: public boolean isNested() {
1078: return (m_nested != null) && !m_nested.isEmpty();
1079: }
1080:
1081: /**
1082: * @return Returns the nested.
1083: */
1084: public List getNested() {
1085: if (m_nested == null) {
1086: m_nested = new Vector();
1087: }
1088: return m_nested;
1089: }
1090:
1091: /**
1092: * @return Returns the nested.
1093: */
1094: public List getNestedInstances() {
1095: List instances = new Vector();
1096: if (m_nested == null) {
1097: m_nested = new Vector();
1098: }
1099: Iterator it = this .m_nested.iterator();
1100: while (it.hasNext()) {
1101: ResourcesMetadata nested = (ResourcesMetadata) it.next();
1102: instances.addAll(nested.m_instances);
1103: }
1104: return instances;
1105: }
1106:
1107: /**
1108: * @param nested The nested to set.
1109: */
1110: public void setNested(List nested) {
1111: m_nested = nested;
1112: }
1113:
1114: /**
1115: * @return Returns the maxValue.
1116: */
1117: public Object getMaxValue() {
1118: return m_maxValue;
1119: }
1120:
1121: /**
1122: * @param maxValue The maxValue to set.
1123: */
1124: public void setMaxValue(Object maxValue) {
1125: m_maxValue = maxValue;
1126: }
1127:
1128: /**
1129: * @return Returns the minValue.
1130: */
1131: public Object getMinValue() {
1132: return m_minValue;
1133: }
1134:
1135: /**
1136: * @param minValue The minValue to set.
1137: */
1138: public void setMinValue(Object minValue) {
1139: m_minValue = minValue;
1140: }
1141:
1142: /**
1143: * @return Returns the pattern.
1144: */
1145: public Pattern getPattern() {
1146: return m_pattern;
1147: }
1148:
1149: /**
1150: * @param pattern The pattern to set.
1151: */
1152: public void setPattern(Pattern pattern) {
1153: m_pattern = pattern;
1154: }
1155:
1156: /**
1157: * @return Returns the maxInclusive.
1158: */
1159: public boolean isMaxInclusive() {
1160: return m_maxInclusive;
1161: }
1162:
1163: /**
1164: * @param maxInclusive The maxInclusive to set.
1165: */
1166: public void setMaxInclusive(boolean maxInclusive) {
1167: m_maxInclusive = maxInclusive;
1168: }
1169:
1170: /**
1171: * @return Returns the minInclusive.
1172: */
1173: public boolean isMinInclusive() {
1174: return m_minInclusive;
1175: }
1176:
1177: /**
1178: * @param minInclusive The minInclusive to set.
1179: */
1180: public void setMinInclusive(boolean minInclusive) {
1181: m_minInclusive = minInclusive;
1182: }
1183:
1184: /**
1185: * @return Returns the depth.
1186: */
1187: public int getDepth() {
1188: return m_depth;
1189: }
1190:
1191: /**
1192: * @param depth The depth to set.
1193: */
1194: public void setDepth(int depth) {
1195: m_depth = depth;
1196: }
1197:
1198: /**
1199: * @param string
1200: */
1201: public void setId(String id) {
1202: m_id = id;
1203:
1204: }
1205:
1206: public String getId() {
1207: return m_id;
1208: }
1209:
1210: public void setDottedparts(List parts) {
1211: m_dottedparts = parts;
1212: }
1213:
1214: public List getDottedparts() {
1215: return m_dottedparts;
1216: }
1217:
1218: public void setDottedpart(int index, String part) {
1219: if (m_dottedparts == null) {
1220: m_dottedparts = new Vector();
1221: }
1222: if (index >= 0 && m_dottedparts.size() < index) {
1223: m_dottedparts.set(index, part);
1224: } else {
1225: m_dottedparts.add(part);
1226: }
1227: }
1228:
1229: public void insertDottedpart(int index, String part) {
1230: if (m_dottedparts == null) {
1231: m_dottedparts = new Vector();
1232: }
1233: if (index >= 0 && index < m_dottedparts.size()) {
1234: m_dottedparts.add(index, part);
1235: } else {
1236: m_dottedparts.add(part);
1237: }
1238: }
1239:
1240: public String getDottedname() {
1241: String name = "";
1242: Iterator it = m_dottedparts.iterator();
1243: while (it.hasNext()) {
1244: String part = (String) it.next();
1245: name += part;
1246: if (it.hasNext()) {
1247: name += DOT;
1248: }
1249: }
1250: return name;
1251: }
1252:
1253: public String getParentname() {
1254: String name = "";
1255: if (m_parent != null) {
1256: name = m_parent.getDottedname();
1257: } else {
1258: boolean first = true;
1259: Iterator it = m_dottedparts.iterator();
1260: while (it.hasNext()) {
1261: String part = (String) it.next();
1262: if (it.hasNext()) {
1263: if (!first) {
1264: name += DOT;
1265: }
1266: name += part;
1267: first = false;
1268: }
1269: }
1270: }
1271: return name;
1272: }
1273:
1274: public void setDottedparts(String path) {
1275: String[] names = path.split(DOT_REGEX);
1276: m_dottedparts = new Vector();
1277: for (int i = 0; i < names.length; i++) {
1278: m_dottedparts.add(names[i]);
1279: }
1280:
1281: }
1282:
1283: /**
1284: * Recursively traverses a hierarchy of ResourcesMetadata objects rooted at this
1285: * node in the hierarchy and returns a flat list of ResourcesMetadata objects.
1286: * The hierarchy is expressed as references in the list of nested objects. The return
1287: * value is a list of objects ordered for rendering as an HTML form, with at least
1288: * one entry for each HTML tag required to render the form.
1289: *
1290: * @return An ordered list of ResourcesMetadata objects.
1291: */
1292: public List getFlatList() {
1293: List rv = new Vector();
1294: rv.add(this );
1295:
1296: Iterator it = this .getNested().iterator();
1297: while (it.hasNext()) {
1298: ResourcesMetadata prop = (ResourcesMetadata) it.next();
1299: if (prop.getMaxCardinality() > 1) {
1300: for (int i = 0; i < prop.getCurrentCount(); i++) {
1301: ResourcesMetadata copy = null;
1302: if (i < prop.m_instances.size()) {
1303: copy = (ResourcesMetadata) prop.m_instances
1304: .get(i);
1305: } else {
1306: copy = new ResourcesMetadata(prop);
1307: List parts = new Vector(this .getDottedparts());
1308: parts.add(copy.getLocalname());
1309: parts.add(Integer.toString(i));
1310: copy.setDottedparts(parts);
1311: copy.setContainer(this );
1312: if (prop.m_parent == null) {
1313: // in that case, prop is the parent
1314: prop.m_instances.add(copy);
1315: copy.m_parent = prop;
1316: } else {
1317: // and otherwise, prop's parent is parent
1318: prop.m_parent.m_instances.add(copy);
1319: //copy.m_parent = prop.m_parent;
1320: }
1321: //copy.m_parent.m_currentCount++;
1322: }
1323:
1324: if (copy.getNested().isEmpty()) {
1325: rv.add(copy);
1326: } else {
1327: rv.addAll(copy.getFlatList());
1328: }
1329: }
1330: } else {
1331: ResourcesMetadata copy = null;
1332: if (prop.m_instances.size() > 0) {
1333: copy = (ResourcesMetadata) prop.m_instances.get(0);
1334: } else {
1335: copy = new ResourcesMetadata(prop);
1336: List parts = new Vector(this .getDottedparts());
1337: parts.add(copy.getLocalname());
1338: copy.setDottedparts(parts);
1339: copy.setContainer(this );
1340: if (prop.m_parent == null) {
1341: // prop is parent
1342: prop.m_instances.add(copy);
1343: copy.m_parent = prop;
1344: } else {
1345: // prop's parent is parent
1346: prop.m_parent.m_instances.add(copy);
1347: //copy.m_parent = prop.m_parent;
1348: }
1349: // copy.m_parent.m_currentCount++;
1350: }
1351:
1352: if (copy.getNested().isEmpty()) {
1353: rv.add(copy);
1354: } else {
1355: rv.addAll(copy.getFlatList());
1356: }
1357: }
1358: }
1359: return rv;
1360:
1361: } // getFlatList
1362:
1363: /**
1364: * Add an instance of "this" property. The dotted-name of the new instance will be the
1365: * same as the dotted-name of "this" property, except that it will have a decimal number
1366: * appended if the property's maximum cardinality allows multiple instances of the property.
1367: */
1368: public ResourcesMetadata addInstance() {
1369: if (this .m_currentCount > this .m_maxCardinality) {
1370: return null;
1371: }
1372: ResourcesMetadata copy = new ResourcesMetadata(this );
1373: copy.setContainer(this .m_container);
1374: List parts = new Vector(this .getDottedparts());
1375: if (this .getMaxCardinality() > 1 && this .m_parent == null) {
1376: parts.add(Integer.toString(this .m_instances.size()));
1377: } else if (this .getMaxCardinality() > 1) {
1378: parts.add(Integer
1379: .toString(this .m_parent.m_instances.size()));
1380: }
1381: copy.setDottedparts(parts);
1382: if (this .m_parent == null) {
1383: this .m_instances.add(copy);
1384: copy.m_parent = this ;
1385: this .setCurrentCount(this .m_instances.size());
1386: } else {
1387: this .m_parent.m_instances.add(copy);
1388: //copy.m_parent = this.m_parent;
1389: this .setCurrentCount(this .m_parent.m_instances.size());
1390: }
1391:
1392: return copy;
1393:
1394: } // addNestedInstance
1395:
1396: } // ResourcesMetadata
|