001: /*******************************************************************************
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: *******************************************************************************/package org.ofbiz.entity.model;
019:
020: import org.ofbiz.base.util.UtilXml;
021: import org.w3c.dom.Element;
022:
023: /**
024: * Generic Entity - Entity model class
025: *
026: */
027: public class ModelInfo {
028:
029: public static final String module = ModelInfo.class.getName();
030:
031: protected ModelInfo def;
032: /** The title for documentation purposes */
033: protected String title = "";
034:
035: /** The description for documentation purposes */
036: protected String description = "";
037:
038: /** The copyright for documentation purposes */
039: protected String copyright = "";
040:
041: /** The author for documentation purposes */
042: protected String author = "";
043:
044: /** The version for documentation purposes */
045: protected String version = "";
046:
047: // ===== CONSTRUCTORS =====
048:
049: public ModelInfo() {
050: this (DEFAULT);
051: }
052:
053: public ModelInfo(ModelInfo def) {
054: this .def = def;
055: }
056:
057: public static final ModelInfo DEFAULT = new ModelInfo() {
058: public String getTitle() {
059: return "None";
060: }
061:
062: public String getAuthor() {
063: return "None";
064: }
065:
066: public String getCopyright() {
067: return "Copyright 2001-2006 The Apache Software Foundation";
068: }
069:
070: public String getVersion() {
071: return "1.0";
072: }
073:
074: public String getDescription() {
075: return "None";
076: }
077: };
078:
079: public void populateFromAttributes(Element element) {
080: author = element.getAttribute("author");
081: copyright = element.getAttribute("copyright");
082: description = UtilXml.childElementValue(element, "description");
083: title = element.getAttribute("title");
084: version = element.getAttribute("version");
085: }
086:
087: public void populateFromElements(Element element) {
088: author = UtilXml.childElementValue(element, "author");
089: copyright = UtilXml.childElementValue(element, "copyright");
090: description = UtilXml.childElementValue(element, "description");
091: title = UtilXml.childElementValue(element, "title");
092: version = UtilXml.childElementValue(element, "version");
093: }
094:
095: // Strings to go in the comment header.
096: /** The title for documentation purposes */
097: public String getTitle() {
098: return this .title != null ? this .title : def.getTitle();
099: }
100:
101: public void setTitle(String title) {
102: this .title = title;
103: }
104:
105: /** The description for documentation purposes */
106: public String getDescription() {
107: return this .description != null ? this .description : def
108: .getDescription();
109: }
110:
111: public void setDescription(String description) {
112: this .description = description;
113: }
114:
115: /** The copyright for documentation purposes */
116: public String getCopyright() {
117: return this .copyright != null ? this .copyright : def
118: .getCopyright();
119: }
120:
121: public void setCopyright(String copyright) {
122: this .copyright = copyright;
123: }
124:
125: /** The author for documentation purposes */
126: public String getAuthor() {
127: return this .author != null ? this .author : def.getAuthor();
128: }
129:
130: public void setAuthor(String author) {
131: this .author = author;
132: }
133:
134: /** The version for documentation purposes */
135: public String getVersion() {
136: return this .version != null ? this .version : def.getVersion();
137: }
138:
139: public void setVersion(String version) {
140: this.version = version;
141: }
142: }
|