01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.jetspeed.serializer.objects;
18:
19: import javolution.xml.XMLFormat;
20: import javolution.xml.stream.XMLStreamException;
21:
22: import org.apache.commons.lang.StringEscapeUtils;
23:
24: public class JSPrincipalRule {
25: // int refID;
26:
27: private String locator;
28:
29: private String rule;
30:
31: public JSPrincipalRule() {
32: }
33:
34: public JSPrincipalRule(String locator, String rule) {
35: // refID = id;
36: this .locator = locator;
37: this .rule = rule;
38: }
39:
40: /***************************************************************************
41: * SERIALIZER
42: */
43: private static final XMLFormat XML = new XMLFormat(
44: JSPrincipalRule.class) {
45: public void write(Object o, OutputElement xml)
46: throws XMLStreamException {
47: try {
48: JSPrincipalRule g = (JSPrincipalRule) o;
49: xml.setAttribute("locator", g.locator);
50: xml.setAttribute("rule", g.rule);
51: } catch (Exception e) {
52: e.printStackTrace();
53: }
54: }
55:
56: public void read(InputElement xml, Object o) {
57: try {
58: JSPrincipalRule g = (JSPrincipalRule) o;
59: g.setLocator(StringEscapeUtils.unescapeHtml(xml
60: .getAttribute("locator", "unknown")));
61: g.setRule(StringEscapeUtils.unescapeHtml(xml
62: .getAttribute("rule", "unknown")));
63:
64: } catch (Exception e) {
65: e.printStackTrace();
66: }
67: }
68:
69: };
70:
71: /**
72: * @return Returns the locator.
73: */
74: public String getLocator() {
75: return locator;
76: }
77:
78: /**
79: * @param locator The locator to set.
80: */
81: public void setLocator(String locator) {
82: this .locator = locator;
83: }
84:
85: /**
86: * @return Returns the rule.
87: */
88: public String getRule() {
89: return rule;
90: }
91:
92: /**
93: * @param rule The rule to set.
94: */
95: public void setRule(String rule) {
96: this.rule = rule;
97: }
98: }
|