1 16 17 package org.apache.xerces.xni.parser; 18 19 import org.apache.xerces.xni.XMLLocator; 20 import org.apache.xerces.xni.XNIException; 21 22 31 public class XMLParseException 32 extends XNIException { 33 34 35 static final long serialVersionUID = 1732959359448549967L; 36 37 41 42 protected String fPublicId; 43 44 45 protected String fLiteralSystemId; 46 47 48 protected String fExpandedSystemId; 49 50 51 protected String fBaseSystemId; 52 53 54 protected int fLineNumber = -1; 55 56 57 protected int fColumnNumber = -1; 58 59 60 protected int fCharacterOffset = -1; 61 62 66 67 public XMLParseException(XMLLocator locator, String message) { 68 super(message); 69 if (locator != null) { 70 fPublicId = locator.getPublicId(); 71 fLiteralSystemId = locator.getLiteralSystemId(); 72 fExpandedSystemId = locator.getExpandedSystemId(); 73 fBaseSystemId = locator.getBaseSystemId(); 74 fLineNumber = locator.getLineNumber(); 75 fColumnNumber = locator.getColumnNumber(); 76 fCharacterOffset = locator.getCharacterOffset(); 77 } 78 } 80 81 public XMLParseException(XMLLocator locator, 82 String message, Exception exception) { 83 super(message, exception); 84 if (locator != null) { 85 fPublicId = locator.getPublicId(); 86 fLiteralSystemId = locator.getLiteralSystemId(); 87 fExpandedSystemId = locator.getExpandedSystemId(); 88 fBaseSystemId = locator.getBaseSystemId(); 89 fLineNumber = locator.getLineNumber(); 90 fColumnNumber = locator.getColumnNumber(); 91 fCharacterOffset = locator.getCharacterOffset(); 92 } 93 } 95 99 100 public String getPublicId() { 101 return fPublicId; 102 } 104 105 public String getExpandedSystemId() { 106 return fExpandedSystemId; 107 } 109 110 public String getLiteralSystemId() { 111 return fLiteralSystemId; 112 } 114 115 public String getBaseSystemId() { 116 return fBaseSystemId; 117 } 119 120 public int getLineNumber() { 121 return fLineNumber; 122 } 124 125 public int getColumnNumber() { 126 return fColumnNumber; 127 } 129 130 public int getCharacterOffset() { 131 return fCharacterOffset; 132 } 134 138 139 public String toString() { 140 141 StringBuffer str = new StringBuffer (); 142 if (fPublicId != null) { 143 str.append(fPublicId); 144 } 145 str.append(':'); 146 if (fLiteralSystemId != null) { 147 str.append(fLiteralSystemId); 148 } 149 str.append(':'); 150 if (fExpandedSystemId != null) { 151 str.append(fExpandedSystemId); 152 } 153 str.append(':'); 154 if (fBaseSystemId != null) { 155 str.append(fBaseSystemId); 156 } 157 str.append(':'); 158 str.append(fLineNumber); 159 str.append(':'); 160 str.append(fColumnNumber); 161 str.append(':'); 162 str.append(fCharacterOffset); 163 str.append(':'); 164 String message = getMessage(); 165 if (message == null) { 166 Exception exception = getException(); 167 if (exception != null) { 168 message = exception.getMessage(); 169 } 170 } 171 if (message != null) { 172 str.append(message); 173 } 174 return str.toString(); 175 176 } 178 } | Popular Tags |