1 16 17 package org.apache.xerces.impl.dtd.models; 18 19 import org.apache.xerces.impl.dtd.XMLContentSpec; 20 import org.apache.xerces.xni.QName; 21 22 29 public class CMLeaf 30 extends CMNode { 31 32 36 37 private QName fElement = new QName(); 38 39 44 private int fPosition = -1; 45 46 50 51 public CMLeaf(QName element, int position) { 52 super(XMLContentSpec.CONTENTSPECNODE_LEAF); 53 54 fElement.setValues(element); 56 fPosition = position; 57 } 58 59 60 public CMLeaf(QName element) { 61 super(XMLContentSpec.CONTENTSPECNODE_LEAF); 62 63 fElement.setValues(element); 65 } 66 67 71 final QName getElement() 72 { 73 return fElement; 74 } 75 76 final int getPosition() 77 { 78 return fPosition; 79 } 80 81 final void setPosition(int newPosition) 82 { 83 fPosition = newPosition; 84 } 85 86 90 92 public boolean isNullable() 93 { 94 return (fPosition == -1); 96 } 97 98 public String toString() 99 { 100 StringBuffer strRet = new StringBuffer (fElement.toString()); 101 strRet.append(" ("); 102 strRet.append(fElement.uri); 103 strRet.append(','); 104 strRet.append(fElement.localpart); 105 strRet.append(')'); 106 if (fPosition >= 0) 107 { 108 strRet.append 109 ( 110 " (Pos:" 111 + Integer.toString(fPosition) 112 + ")" 113 ); 114 } 115 return strRet.toString(); 116 } 117 118 120 protected void calcFirstPos(CMStateSet toSet) 121 { 122 if (fPosition == -1) 124 toSet.zeroBits(); 125 126 else 128 toSet.setBit(fPosition); 129 } 130 131 protected void calcLastPos(CMStateSet toSet) 132 { 133 if (fPosition == -1) 135 toSet.zeroBits(); 136 137 else 139 toSet.setBit(fPosition); 140 } 141 142 } 144 145 | Popular Tags |