001: /*
002: * Jacareto Copyright (c) 2002-2005
003: * Applied Computer Science Research Group, Darmstadt University of
004: * Technology, Institute of Mathematics & Computer Science,
005: * Ludwigsburg University of Education, and Computer Based
006: * Learning Research Group, Aachen University. All rights reserved.
007: *
008: * Jacareto is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation; either
011: * version 2 of the License, or (at your option) any later version.
012: *
013: * Jacareto is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * General Public License for more details.
017: *
018: * You should have received a copy of the GNU General Public
019: * License along with Jacareto; if not, write to the Free
020: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021: *
022: */
023:
024: package jacareto.struct;
025:
026: import jacareto.parse.RecordTokenizer;
027: import jacareto.record.ReadAccessRecord;
028: import jacareto.system.Environment;
029: import jacareto.system.EnvironmentMember;
030:
031: /**
032: * A compound of a record and its structure. If the compound is created from a record only, the
033: * structure is built automatically.
034: *
035: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
036: * @version 1.00
037: */
038: public class RecordStructureCompound extends EnvironmentMember {
039: /** The record. */
040: private ReadAccessRecord record;
041:
042: /** The structure of the record. */
043: private Structure structure;
044:
045: /**
046: * Creates a RecordStructureCompound with the given record and environment. The structure is
047: * built automatically with the root element of the type defined in the customization, key
048: * <code>RootElement.Type</code>.
049: *
050: * @param env The environment
051: * @param record The record
052: */
053: public RecordStructureCompound(Environment env,
054: ReadAccessRecord record) {
055: super (env);
056: applyRecord(record);
057: }
058:
059: /**
060: * Creates a new RecordStructureCompound with the given values.
061: *
062: * @param env the environment
063: * @param record the record
064: * @param structure the structure of the record
065: */
066: public RecordStructureCompound(Environment env,
067: ReadAccessRecord record, Structure structure) {
068: super (env);
069: setRecord(record);
070: setStructure(structure);
071: }
072:
073: /**
074: * Returns the record.
075: *
076: * @return the record
077: */
078: public ReadAccessRecord getRecord() {
079: return record;
080: }
081:
082: /**
083: * Returns the structure of the record.
084: *
085: * @return the structure
086: */
087: public Structure getStructure() {
088: return structure;
089: }
090:
091: /**
092: * Sets the record.
093: *
094: * @param record the new record
095: */
096: public void setRecord(ReadAccessRecord record) {
097: this .record = record;
098: }
099:
100: /**
101: * Sets the structure.
102: *
103: * @param structure the new structure
104: */
105: public void setStructure(Structure structure) {
106: this .structure = structure;
107: }
108:
109: /**
110: * Sets the record. The structure will be built automatically with the root element of the type
111: * defined in the customization, key <code>RootElement.Type</code>.
112: *
113: * @param record The record
114: */
115: public void applyRecord(ReadAccessRecord record) {
116: setRecord(record);
117: setStructure(new Structure(env, record));
118: }
119:
120: /**
121: * Rebuilds the structure from the record. The structure is built automatically with the root
122: * element of the type defined in the customization, key <code>RootElement.Type</code>.
123: */
124: public void rebuildStructure() {
125: structure.rebuild(new RecordTokenizer(env, record));
126: structure.getRootElement().setRecord(record);
127: }
128: }
|