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: package org.apache.jetspeed.serializer.objects;
018:
019: import javolution.xml.XMLFormat;
020: import javolution.xml.stream.XMLStreamException;
021:
022: import org.apache.commons.lang.StringEscapeUtils;
023:
024: public class JSSimpleIDName {
025: // private int refID;
026:
027: private String name;
028:
029: private int id;
030:
031: public JSSimpleIDName() {
032: // refID = id;
033: }
034:
035: public JSSimpleIDName(int id, String name) {
036: this .id = id;
037: this .name = name;
038: // refID = id;
039: }
040:
041: /***************************************************************************
042: * SERIALIZER
043: */
044: private static final XMLFormat XML = new XMLFormat(
045: JSSimpleIDName.class) {
046: public void write(Object o, OutputElement xml)
047: throws XMLStreamException {
048:
049: try {
050: JSSimpleIDName g = (JSSimpleIDName) o;
051: xml.setAttribute("name", g.name);
052: xml.setAttribute("id", g.id);
053:
054: } catch (Exception e) {
055: e.printStackTrace();
056: }
057: }
058:
059: public void read(InputElement xml, Object o) {
060: try {
061: JSSimpleIDName g = (JSSimpleIDName) o;
062: g.setName(StringEscapeUtils.unescapeHtml(xml
063: .getAttribute("name", "Unknown")));
064: g.setId(xml.getAttribute("id", 0));
065:
066: } catch (Exception e) {
067: e.printStackTrace();
068: }
069: }
070: };
071:
072: /**
073: * @return Returns the name.
074: */
075: public String getName() {
076: return name;
077: }
078:
079: /**
080: * @param name
081: * The name to set.
082: */
083: public void setName(String name) {
084: this .name = name;
085: }
086:
087: /**
088: * @return Returns the id.
089: */
090: public int getId() {
091: return id;
092: }
093:
094: /**
095: * @param id The id to set.
096: */
097: public void setId(int id) {
098: this.id = id;
099: }
100:
101: }
|