1 57 58 package com.sun.org.apache.xerces.internal.impl.dtd.models; 59 60 import com.sun.org.apache.xerces.internal.impl.dtd.XMLContentSpec; 61 import com.sun.org.apache.xerces.internal.xni.QName; 62 63 68 public class CMLeaf 69 extends CMNode { 70 71 75 76 private QName fElement = new QName(); 77 78 83 private int fPosition = -1; 84 85 89 90 public CMLeaf(QName element, int position) { 91 super(XMLContentSpec.CONTENTSPECNODE_LEAF); 92 93 fElement.setValues(element); 95 fPosition = position; 96 } 97 98 99 public CMLeaf(QName element) { 100 super(XMLContentSpec.CONTENTSPECNODE_LEAF); 101 102 fElement.setValues(element); 104 } 105 106 110 final QName getElement() 111 { 112 return fElement; 113 } 114 115 final int getPosition() 116 { 117 return fPosition; 118 } 119 120 final void setPosition(int newPosition) 121 { 122 fPosition = newPosition; 123 } 124 125 129 131 public boolean isNullable() 132 { 133 return (fPosition == -1); 135 } 136 137 public String toString() 138 { 139 StringBuffer strRet = new StringBuffer (fElement.toString()); 140 strRet.append(" ("); 141 strRet.append(fElement.uri); 142 strRet.append(','); 143 strRet.append(fElement.localpart); 144 strRet.append(')'); 145 if (fPosition >= 0) 146 { 147 strRet.append 148 ( 149 " (Pos:" 150 + new Integer (fPosition).toString() 151 + ")" 152 ); 153 } 154 return strRet.toString(); 155 } 156 157 159 protected void calcFirstPos(CMStateSet toSet) 160 { 161 if (fPosition == -1) 163 toSet.zeroBits(); 164 165 else 167 toSet.setBit(fPosition); 168 } 169 170 protected void calcLastPos(CMStateSet toSet) 171 { 172 if (fPosition == -1) 174 toSet.zeroBits(); 175 176 else 178 toSet.setBit(fPosition); 179 } 180 181 } 183 184 | Popular Tags |