View Javadoc
1 package jsdsi; 2 3 import java.util.Iterator; 4 5 import jsdsi.sexp.Sexp; 6 import jsdsi.sexp.SexpList; 7 import jsdsi.sexp.SexpParseException; 8 import jsdsi.sexp.SexpUtil; 9 10 /*** 11 * Specifies a particular authorization permission. 12 * 13 * @author Sameer Ajmani 14 * @author Sean Radford 15 * @version $Revision: 1.3.2.1 $ $Date: 2005/11/08 03:12:52 $ 16 */ 17 public abstract class Tag extends Obj { 18 19 private static final long serialVersionUID = -2237651253804555846L; 20 21 /*** 22 * A <code>Tag</code> that conveys all permissions. 23 */ 24 public static Tag ALL_TAG = new Tag() { 25 public Tag intersect(Tag that) { 26 return that; 27 } 28 29 public boolean equals(Object that) { 30 return this == that; 31 } 32 33 public int hashCode() { 34 return 1; 35 } 36 37 public Sexp toTagSexp() { 38 return SexpUtil.toSexpList("*"); 39 } 40 }; 41 42 /*** 43 * A Tag that conveys no permissions. 44 */ 45 public static Tag NULL_TAG = new Tag() { 46 public Tag intersect(Tag that) { 47 return this; 48 } 49 50 public boolean equals(Object that) { 51 return this == that; 52 } 53 54 public int hashCode() { 55 return 0; 56 } 57 58 public Sexp toTagSexp() { 59 throw new Error("Cannot convert NULL_TAG to Sexp"); 60 } 61 62 public String toString() 63 { 64 return "Tag.NULL_TAG"; 65 } 66 }; 67 68 /*** 69 * Intersects this <code>Tag</code> with another one and returns the 70 * result. 71 * 72 * @param that tag to intersect this with. 73 * @return the intersection of this <code>Tag</code> and <code>that</code>. 74 */ 75 public abstract Tag intersect(Tag that); 76 77 /*** 78 * Checks if this <code>Tag</code> implies the given tag. 79 * Implemented as <code>return this.intersect(that).equals(that)</code>. 80 * 81 * @param that tag to check for if it is implied by this one. 82 * @return <code>true</code> if this tag implies <code>that</code>, 83 * <code>false</code> otherwise. 84 */ 85 public final boolean implies(Tag that) { 86 return this.intersect(that).equals(that); 87 } 88 89 abstract protected Sexp toTagSexp(); 90 91 public final SexpList toSexp() { 92 Sexp[] ss = new Sexp[1]; 93 ss[0] = toTagSexp(); 94 return SexpUtil.toSexp("tag", ss); 95 } 96 97 static Tag parseTag(SexpList l) throws SexpParseException { 98 SexpUtil.checkType(l, "tag"); 99 Iterator tbody = SexpUtil.getBody(l); 100 Sexp s = SexpUtil.getNext(tbody, "tag body"); 101 if (s instanceof SexpList) { 102 SexpList ll = (SexpList) s; 103 if (ll.getType().equals("*") && (ll.size() == 1)) { 104 return ALL_TAG; 105 } 106 } 107 return ExprTag.parseExprTag(s); 108 } 109 }

This page was automatically generated by Maven