View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      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  import javolution.xml.XMLFormat;
19  import javolution.xml.stream.XMLStreamException;
20  
21  import org.apache.commons.lang.StringEscapeUtils;
22  
23  public class JSPrincipalRule
24  {
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  	{
36  //		refID = id;
37  		this.locator = locator;
38  		this.rule = rule;
39  	}
40  
41  	/****************************************************************************
42  	 * SERIALIZER
43  	 */
44  	private static final XMLFormat XML = new XMLFormat(JSPrincipalRule.class)
45  	{
46  		public void write(Object o, OutputElement xml)
47  				throws XMLStreamException
48  		{
49  			try
50  			{
51  				JSPrincipalRule g = (JSPrincipalRule) o;
52  				xml.setAttribute("locator", g.locator);
53  				xml.setAttribute("rule", g.rule);
54  			} catch (Exception e)
55  			{
56  				e.printStackTrace();
57  			}
58  		}
59  
60  		public void read(InputElement xml, Object o)
61  		{
62  			try
63  			{
64  				JSPrincipalRule g = (JSPrincipalRule) o;
65  				g.setLocator(StringEscapeUtils.unescapeHtml(xml.getAttribute("locator","unknown")));
66  				g.setRule(StringEscapeUtils.unescapeHtml(xml.getAttribute("rule","unknown")));
67  				
68  				
69  			} catch (Exception e)
70  			{
71  				e.printStackTrace();
72  			}
73  		}
74  
75  	};
76  
77  
78  
79  
80  	/***
81  	 * @return Returns the locator.
82  	 */
83  	public String getLocator()
84  	{
85  		return locator;
86  	}
87  
88  	/***
89  	 * @param locator The locator to set.
90  	 */
91  	public void setLocator(String locator)
92  	{
93  		this.locator = locator;
94  	}
95  
96  	/***
97  	 * @return Returns the rule.
98  	 */
99  	public String getRule()
100 	{
101 		return rule;
102 	}
103 
104 	/***
105 	 * @param rule The rule to set.
106 	 */
107 	public void setRule(String rule)
108 	{
109 		this.rule = rule;
110 	}
111 }