Skip to content

Commit cb72d71

Browse files
committed
Add a few javadoc comments.
1 parent dfc92ae commit cb72d71

File tree

5 files changed

+138
-1
lines changed

5 files changed

+138
-1
lines changed

build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ tasks.withType(JavaCompile) {
129129
}
130130

131131
tasks.withType(Javadoc) {
132-
failOnError false
133132
options.addStringOption('Xdoclint:none', '-quiet')
134133
options.addStringOption('encoding', 'UTF-8')
135134
options.addStringOption('charset', 'UTF-8')

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ public class ContentModel {
4040

4141
private static final int DTD_SIZE_LIMIT = 0x100000;
4242

43+
/**
44+
* Construct a new {@code ContentModel} with the given set of <code>EMPTY</code>
45+
* elements.
46+
*
47+
* @param emptyElements the set of names of <code>EMPTY</code> elements.
48+
*/
4349
private ContentModel(Set<String> emptyElements) {
4450
super();
4551
this.emptyElements = emptyElements;

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

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,71 @@ protected boolean registerSystemIdFilename(String systemId, String filename) {
322322
return ret == null;
323323
}
324324

325+
/**
326+
* Allows applications to map references to external entities into input
327+
* sources.
328+
* <p>
329+
* This method is only called for external entities which have been properly
330+
* declared. It provides more flexibility than the
331+
* {@link org.xml.sax.EntityResolver EntityResolver} interface, supporting
332+
* implementations of more complex catalogue schemes such as the one defined by
333+
* the
334+
* <a href= "http://www.oasis-open.org/committees/entity/spec-2001-08-06.html"
335+
* >OASIS XML Catalogs</a> specification.
336+
* </p>
337+
* <p>
338+
* Parsers configured to use this resolver method will call it to determine the
339+
* input source to use for any external entity being included because of a
340+
* reference in the XML text. That excludes the document entity, and any
341+
* external entity returned by {@link #getExternalSubset getExternalSubset()}.
342+
* When a (non-validating) processor is configured not to include a class of
343+
* entities (parameter or general) through use of feature flags, this method is
344+
* not invoked for such entities.
345+
* </p>
346+
* <p>
347+
* If no valid input source could be determined, this method will throw a
348+
* {@code SAXException} instead of returning {@code null} as other
349+
* implementations would do. If you have to retrieve a DTD which is not directly
350+
* provided by this resolver, you need to whitelist the host using
351+
* {@link #addHostToWhiteList(String)} first. Make sure that either the systemId
352+
* URL ends with a valid extension, or that the retrieved URL was served with a
353+
* valid DTD media type.
354+
* </p>
355+
* <p>
356+
* Note that the entity naming scheme used here is the same one used in the
357+
* {@link org.xml.sax.ext.LexicalHandler LexicalHandler}, or in the
358+
* {@link org.xml.sax.ContentHandler#skippedEntity
359+
* ContentHandler.skippedEntity()} method.
360+
* </p>
361+
*
362+
* @param name Identifies the external entity being resolved. Either
363+
* "{@code [dtd]}" for the external subset, or a name starting
364+
* with "{@code %}" to indicate a parameter entity, or else the
365+
* name of a general entity. This is never {@code null} when
366+
* invoked by a SAX2 parser.
367+
* @param publicId The public identifier of the external entity being referenced
368+
* (normalized as required by the XML specification), or
369+
* {@code null} if none was supplied.
370+
* @param baseURI The URI with respect to which relative systemIDs are
371+
* interpreted. This is always an absolute URI, unless it is
372+
* {@code null} (likely because the {@code XMLReader} was given
373+
* an {@code InputSource} without one). This URI is defined by
374+
* the XML specification to be the one associated with the
375+
* "{@literal <}" starting the relevant declaration.
376+
* @param systemId The system identifier of the external entity being
377+
* referenced; either a relative or absolute URI. This is never
378+
* {@code null} when invoked by a SAX2 parser; only declared
379+
* entities, and any external subset, are resolved by such
380+
* parsers.
381+
*
382+
* @return an {@code InputSource} object describing the new input source to be
383+
* used by the parser. This implementation never returns {@code null}.
384+
*
385+
* @throws SAXException if either the provided arguments or the input
386+
* source were invalid or not allowed.
387+
* @throws java.io.IOException if an I/O problem was found while forming the URL
388+
* to the input source, or when connecting to it.
389+
*/
325390
@Override
326391
public final InputSource resolveEntity(String name, String publicId, String baseURI, String systemId)
327392
throws SAXException, IOException {
@@ -498,15 +563,73 @@ protected boolean isValidContentType(String conType) {
498563
|| conType.equals("application/xml-external-parsed-entity"));
499564
}
500565

566+
/**
567+
* Allow the application to resolve external entities.
568+
*
569+
* <p>
570+
* The parser will call this method before opening any external entity except
571+
* the top-level document entity. Such entities include the external DTD subset
572+
* and external parameter entities referenced within the DTD (in either case,
573+
* only if the parser reads external parameter entities), and external general
574+
* entities referenced within the document element (if the parser reads external
575+
* general entities). The application may request that the parser locate the
576+
* entity itself, that it use an alternative URI, or that it use data provided
577+
* by the application (as a character or byte input stream).
578+
* </p>
579+
* <p>
580+
* If no valid input source could be determined, this method will throw a
581+
* {@code SAXException} instead of returning {@code null} as other
582+
* implementations would do. If you have to retrieve a DTD which is not directly
583+
* provided by this resolver, you need to whitelist the host using
584+
* {@link #addHostToWhiteList(String)} first. Make sure that either the systemId
585+
* URL ends with a valid extension, or that the retrieved URL was served with a
586+
* valid DTD media type.
587+
* </p>
588+
*
589+
* @param publicId The public identifier of the external entity being
590+
* referenced, or {@code null} if none was supplied.
591+
* @param systemId The system identifier of the external entity being
592+
* referenced.
593+
* @return an {@code InputSource} object describing the new input source. This
594+
* implementation never returns {@code null}.
595+
* @throws SAXException if either the provided arguments or the input
596+
* source were invalid or not allowed.
597+
* @throws java.io.IOException if an I/O problem was found while forming the URL
598+
* to the input source, or when connecting to it.
599+
*/
501600
@Override
502601
public final InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
503602
return resolveEntity(null, publicId, null, systemId);
504603
}
505604

605+
/**
606+
* Resolve external entities according to the given {@code DocumentType}.
607+
* <p>
608+
* If no valid input source could be determined, this method will throw a
609+
* {@code SAXException} instead of returning {@code null} as other
610+
* implementations would do. If you have to retrieve a DTD which is not directly
611+
* provided by this resolver, you need to whitelist the host using
612+
* {@link #addHostToWhiteList(String)} first. Make sure that either the systemId
613+
* URL ends with a valid extension, or that the retrieved URL was served with a
614+
* valid DTD media type.
615+
* </p>
616+
*
617+
* @param dtDecl the {@code DocumentType}.
618+
* @return an {@code InputSource} object describing the new input source.
619+
* @throws SAXException if either the provided arguments or the input
620+
* source were invalid or not allowed.
621+
* @throws java.io.IOException if an I/O problem was found while forming the URL
622+
* to the input source, or when connecting to it.
623+
*/
506624
public InputSource resolveEntity(DocumentType dtDecl) throws SAXException, IOException {
507625
return resolveEntity(dtDecl.getName(), dtDecl.getPublicId(), dtDecl.getBaseURI(), dtDecl.getSystemId());
508626
}
509627

628+
/**
629+
* Set the class loader to be used to read the built-in DTDs.
630+
*
631+
* @param loader the class loader.
632+
*/
510633
public void setClassLoader(ClassLoader loader) {
511634
this.loader = loader;
512635
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public class EntityFinder {
3737

3838
private static final int DTD_SIZE_LIMIT = 0x100000;
3939

40+
/**
41+
* Construct a new EntityFinder that uses the given {@code EntityResolver2}.
42+
*
43+
* @param resolver the resolver to use when resolving the entities.
44+
*/
4045
public EntityFinder(EntityResolver2 resolver) {
4146
super();
4247
this.resolver = resolver;

src/module-info.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
* https://css4j.github.io/LICENSE.txt
99
*
1010
*/
11+
12+
/**
13+
* DTD-related helper classes for XML parsing.
14+
*/
1115
module io.sf.carte.xml.dtd {
1216
exports io.sf.carte.doc.xml.dtd;
1317

0 commit comments

Comments
 (0)