Skip to content

Commit 217dd86

Browse files
committed
Remove DefaultEntityResolver.resolveEntity(String)
See #1
1 parent 49a8093 commit 217dd86

File tree

3 files changed

+14
-37
lines changed

3 files changed

+14
-37
lines changed

junit/io/sf/carte/doc/xml/dtd/DefaultEntityResolverTest.java

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ public void resolveEntityStringStringRemote() throws SAXException, IOException {
163163
}
164164

165165
@Test
166-
public void resolveEntityString() throws SAXException, IOException {
167-
@SuppressWarnings("removal")
168-
InputSource isrc = resolver.resolveEntity(DocumentTypeDeclaration.XHTML1_TRA_DTDECL);
166+
public void parseAndResolveEntity() throws SAXException, IOException {
167+
DocumentTypeDeclaration dtDecl = DocumentTypeDeclaration.parse(DocumentTypeDeclaration.XHTML1_TRA_DTDECL);
168+
InputSource isrc = resolver.resolveEntity(dtDecl.getName(), dtDecl.getPublicId(), null, dtDecl.getSystemId());
169169
assertNotNull(isrc);
170170
assertNotNull(isrc.getPublicId());
171171
assertEquals(DocumentTypeDeclaration.XHTML1_TRA_PUBLICID, isrc.getPublicId());
@@ -174,18 +174,6 @@ public void resolveEntityString() throws SAXException, IOException {
174174
re.close();
175175
}
176176

177-
@SuppressWarnings("removal")
178-
@Test
179-
public void resolveNonexistentDeclaration() {
180-
try {
181-
resolver.resolveEntity("hi");
182-
fail("Must throw exception");
183-
} catch (SAXException e) {
184-
} catch (IOException e) {
185-
fail("Should throw SAXException, not IOException");
186-
}
187-
}
188-
189177
@Test
190178
public void resolveNonexistent() {
191179
// No SystemId, so it should resolve to null

junit/io/sf/carte/doc/xml/dtd/DocumentTypeDeclarationTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import static org.junit.Assert.assertEquals;
1515
import static org.junit.Assert.assertNull;
16+
import static org.junit.Assert.fail;
1617

1718
import org.junit.Test;
1819
import org.xml.sax.SAXException;
@@ -36,6 +37,7 @@ public void parse() throws SAXException {
3637
assertEquals("html", dtdecl.getName());
3738
assertEquals("-//W3C//DTD XHTML 1.0 Transitional//EN", dtdecl.getPublicId());
3839
assertEquals("http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd", dtdecl.getSystemId());
40+
3941
dtdecl = DocumentTypeDeclaration.parse(ContentModelTest.DTD_NONEXISTENT);
4042
assertEquals("hi", dtdecl.getName());
4143
assertEquals("-//HI//Does not exist//EN", dtdecl.getPublicId());
@@ -51,6 +53,15 @@ public void parse2() throws SAXException {
5153
assertEquals("http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd", dtdecl.getSystemId());
5254
}
5355

56+
@Test
57+
public void parseBadDtd() throws SAXException {
58+
try {
59+
DocumentTypeDeclaration.parse("hi");
60+
fail("Must throw exception");
61+
} catch (SAXException e) {
62+
}
63+
}
64+
5465
@Test
5566
public void testToString() throws SAXException {
5667
DocumentTypeDeclaration dtdecl = DocumentTypeDeclaration.parse(

src/io/sf/carte/doc/xml/dtd/DefaultEntityResolver.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -515,28 +515,6 @@ public InputSource resolveEntity(DocumentType dtDecl) throws SAXException, IOExc
515515
return resolveEntity(dtDecl.getName(), dtDecl.getPublicId(), dtDecl.getBaseURI(), dtDecl.getSystemId());
516516
}
517517

518-
/**
519-
* Resolve the given DTD string.
520-
*
521-
* @param documentTypeDeclaration the document type declaration.
522-
* @return an InputSource object describing the new input source to be used by
523-
* the parser.
524-
* @throws SAXException Any SAX exception, possibly wrapping another exception.
525-
* @throws IOException indicating a failure to create a new InputStream or
526-
* Reader, or an illegal URL.
527-
* @deprecated This method uses the {@link DocumentTypeDeclaration} type, which
528-
* carries a dependency with the {@code jclf-text} module, and is
529-
* going to be removed to make the class a bit lighter. People
530-
* needing this functionality can always parse the DTD string on
531-
* their own with {@link DocumentTypeDeclaration#parse(String)} and
532-
* then call {@link #resolveEntity(String, String, String, String)}.
533-
*/
534-
@Deprecated(forRemoval=true)
535-
public InputSource resolveEntity(String documentTypeDeclaration) throws SAXException, IOException {
536-
DocumentTypeDeclaration dtDecl = DocumentTypeDeclaration.parse(documentTypeDeclaration);
537-
return resolveEntity(dtDecl.getName(), dtDecl.getPublicId(), null, dtDecl.getSystemId());
538-
}
539-
540518
public void setClassLoader(ClassLoader loader) {
541519
this.loader = loader;
542520
}

0 commit comments

Comments
 (0)