View Javadoc
1 /* 2 * $Header: /cvsroot/ebxmlrr/ebxmlrr/src/share/com/sun/ebxml/registry/security/authorization/ObjectAttribute.java,v 1.1 2003/06/20 14:26:10 farrukh_najmi Exp $ 3 * 4 * ==================================================================== 5 * 6 * This code is subject to the freebxml License, Version 1.1 7 * 8 * Copyright (c) 2003 freebxml.org. All rights reserved. 9 * 10 * ==================================================================== 11 */ 12 13 package com.sun.ebxml.registry.security.authorization; 14 15 import java.net.URI; 16 17 import org.w3c.dom.Node; 18 import com.sun.xacml.attr.AttributeValue; 19 20 /*** 21 * Representation of an java.lang.Object value. 22 * All objects of this class are immutable and 23 * all methods of the class are thread-safe. 24 * 25 * @author Farrukh Najmi 26 */ 27 public class ObjectAttribute extends AttributeValue 28 { 29 /*** 30 * Official name of this type 31 */ 32 public static final String identifier = 33 "http://www.w3.org/2001/XMLSchema#object"; //What should this be?? 34 35 /*** 36 * URI version of name for this type 37 * <p> 38 * This field is initialized by a static initializer so that 39 * we can catch any exceptions thrown by URI(String) and 40 * transform them into a RuntimeException, since this should 41 * never happen but should be reported properly if it ever does. 42 */ 43 private static URI identifierURI; 44 45 /*** 46 * RuntimeException that wraps an Exception thrown during the 47 * creation of identifierURI, null if none. 48 */ 49 private static RuntimeException earlyException; 50 51 /*** 52 * Static initializer that initializes the identifierURI 53 * class field so that we can catch any exceptions thrown 54 * by URI(String) and transform them into a RuntimeException. 55 * Such exceptions should never happen but should be reported 56 * properly if they ever do. 57 */ 58 static { 59 try { 60 identifierURI = new URI(identifier); 61 } catch (Exception e) { 62 earlyException = new IllegalArgumentException(); 63 earlyException.initCause(e); 64 } 65 }; 66 67 /*** 68 * The actual Object value that this object represents. 69 */ 70 private Object value; 71 72 /*** 73 * Creates a new <code>ObjectAttribute</code> that represents 74 * the Object value supplied. 75 * 76 * @param value the <code>Object</code> value to be represented 77 */ 78 public ObjectAttribute(Object value) { 79 super(identifierURI); 80 81 // Shouldn't happen, but just in case... 82 if (earlyException != null) 83 throw earlyException; 84 85 this.value = value; 86 } 87 88 /*** 89 * Returns a new <code>ObjectAttribute</code> that represents 90 * a java.lang.Object. 91 * 92 * @param root the <code>Node</code> that contains the desired value 93 * @return a new <code>ObjectAttribute</code> representing the 94 * appropriate value (null if there is a parsing error) 95 */ 96 public static ObjectAttribute getInstance(Node root) { 97 return getInstance(root.getFirstChild().getNodeValue()); 98 } 99 100 /*** 101 * Returns a new <code>ObjectAttribute</code> that represents 102 * the Object value indicated by the <code>Object</code> provided. 103 * 104 * @param value a Object representing the desired value 105 * @return a new <code>ObjectAttribute</code> representing the 106 * appropriate value 107 */ 108 public static ObjectAttribute getInstance(Object value) { 109 return new ObjectAttribute(value); 110 } 111 112 /*** 113 * Returns the <code>Object</code> value represented by this object. 114 * 115 * @return the <code>Object</code> value 116 */ 117 public Object getValue() { 118 return value; 119 } 120 121 /*** 122 * Returns true if the input is an instance of this class and if its 123 * value equals the value contained in this class. 124 * 125 * @param o the object to compare 126 * 127 * @return true if this object and the input represent the same value 128 */ 129 public boolean equals(Object o) { 130 if (! (o instanceof ObjectAttribute)) 131 return false; 132 133 ObjectAttribute other = (ObjectAttribute)o; 134 135 return value.equals(other.value); 136 } 137 138 /*** 139 * Returns the hashcode value used to index and compare this object with 140 * others of the same type. Typically this is the hashcode of the backing 141 * data object. 142 * 143 * @return the object's hashcode value 144 */ 145 public int hashCode() { 146 return value.hashCode(); 147 } 148 149 /*** 150 * Converts to a String representation. 151 * 152 * @return the String representation 153 */ 154 public String toString() { 155 return "ObjectAttribute: \"" + value + "\""; 156 } 157 158 /*** 159 * 160 */ 161 public String encode() { 162 return value.toString(); 163 } 164 165 }

This page was automatically generated by Maven