1 29 30 package com.caucho.relaxng.pattern; 31 32 import com.caucho.relaxng.RelaxException; 33 import com.caucho.relaxng.program.NameClassItem; 34 import com.caucho.relaxng.program.NsNameItem; 35 36 39 public class NsNamePattern extends NameClassPattern { 40 private String _name; 41 private String _ns; 42 43 private NameClassPattern _except; 44 45 private NsNameItem _item; 46 47 50 public NsNamePattern() 51 { 52 } 53 54 57 public NsNamePattern(String ns) 58 { 59 _ns = ns; 60 } 61 62 65 public NsNamePattern(String name, String ns) 66 { 67 _name = name; 68 _ns = ns; 69 } 70 71 public void setNamespace(String ns) 72 { 73 _ns = ns; 74 } 75 76 79 public String getTagName() 80 { 81 return "nsName"; 82 } 83 84 87 public void setExcept(NameClassPattern pattern) 88 { 89 _except = pattern; 90 } 91 92 95 public NameClassItem createNameItem() 96 throws RelaxException 97 { 98 if (_item == null) { 99 NsNameItem item = new NsNameItem(_ns); 100 101 if (_except != null) 102 item.setExcept(_except.createNameItem()); 103 104 _item = item; 105 } 106 107 return _item; 108 } 109 110 113 public String toProduction() 114 { 115 if (_except == null) 116 return _ns + ":*"; 117 else 118 return "(" + _ns + ":* - " + _except + ")"; 119 } 120 121 public boolean equals(Object o) 122 { 123 if (this == o) 124 return true; 125 126 if (! (o instanceof NsNamePattern)) 127 return false; 128 129 NsNamePattern pattern = (NsNamePattern) o; 130 131 if (! _ns.equals(pattern._ns)) 132 return false; 133 134 if (_except == null) 135 return pattern._except == null; 136 else 137 return _except.equals(pattern._except); 138 } 139 140 143 public String toString() 144 { 145 return "NsName[" + _ns + "]"; 146 } 147 } 148 149 | Popular Tags |