001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.jetspeed.serializer.objects;
019:
020: import javolution.xml.XMLFormat;
021: import javolution.xml.stream.XMLStreamException;
022:
023: public class JSSecondaryData extends JSSnapshot {
024:
025: public static final int softwareVersion = 1;
026:
027: public static final int softwareSubVersion = 0;
028:
029: private String encryption;
030:
031: private JSApplications applications;
032:
033: /**
034: * check the software version and subvversion against the saved
035: * version...and verify whether it is compatible...
036: *
037: * @return the current software can process this file
038: */
039: public boolean checkVersion() {
040: return true;
041: }
042:
043: /**
044: * @return Returns the softwareSubVersion.
045: */
046: public int getSoftwareSubVersion() {
047: return softwareSubVersion;
048: }
049:
050: /**
051: * @return Returns the softwareVersion.
052: */
053: public int getSoftwareVersion() {
054: return softwareVersion;
055: }
056:
057: public JSSecondaryData() {
058: super ();
059: System.out.println("JSSecondaryData Class created");
060: }
061:
062: public JSSecondaryData(String name) {
063: super ();
064:
065: applications = new JSApplications();
066: }
067:
068: /***************************************************************************
069: * SERIALIZER
070: */
071: protected static final XMLFormat XML = new XMLFormat(
072: JSSecondaryData.class) {
073:
074: public void write(Object o, OutputElement xml)
075: throws XMLStreamException {
076:
077: try {
078:
079: JSSnapshot.XML.write(o, xml);
080:
081: JSSecondaryData g = (JSSecondaryData) o;
082:
083: /** implicitly named (through binding) fields here */
084:
085: xml.add(g.getApplications());
086:
087: } catch (Exception e) {
088: e.printStackTrace();
089: }
090: }
091:
092: public void read(InputElement xml, Object o) {
093: try {
094: JSSnapshot.XML.read(xml, o); // Calls parent read.
095: JSSecondaryData g = (JSSecondaryData) o;
096:
097: while (xml.hasNext()) {
098: Object o1 = xml.getNext(); // mime
099:
100: if (o1 instanceof JSApplications)
101: g.applications = (JSApplications) o1;
102: }
103: } catch (Exception e) {
104: e.printStackTrace();
105: }
106: }
107: };
108:
109: /**
110: * @param applications
111: * The applications to set.
112: */
113: public void setApplications(JSApplications applications) {
114: this .applications = applications;
115: }
116:
117: public JSApplications getApplications() {
118: return applications;
119: }
120:
121: }
|