Skip to content

Commit 0adac1e

Browse files
committed
Merge branch 'xml-import-simple-mode'
2 parents 567869a + 05b31ce commit 0adac1e

17 files changed

+911
-2062
lines changed

src/main/java/de/catma/document/source/contenthandler/AbstractSourceContentHandler.java

+24-39
Original file line numberDiff line numberDiff line change
@@ -18,40 +18,28 @@
1818
*/
1919
package de.catma.document.source.contenthandler;
2020

21-
import java.io.IOException;
22-
2321
import de.catma.document.source.SourceDocumentInfo;
2422

23+
import java.io.IOException;
24+
2525
/**
2626
* Basic implementation that provides lazy loading.
27-
*
28-
29-
*
3027
*/
3128
public abstract class AbstractSourceContentHandler implements SourceContentHandler {
29+
private SourceDocumentInfo sourceDocumentInfo;
30+
private String content;
3231

33-
private SourceDocumentInfo sourceDocumentInfo;
34-
private String content;
35-
36-
/* (non-Javadoc)
37-
* @see de.catma.document.source.contenthandler.SourceContentHandler#setSourceDocumentInfo(de.catma.document.source.SourceDocumentInfo)
38-
*/
39-
public void setSourceDocumentInfo(SourceDocumentInfo sourceDocumentInfo) {
32+
@Override
33+
public void setSourceDocumentInfo(SourceDocumentInfo sourceDocumentInfo) {
4034
this.sourceDocumentInfo = sourceDocumentInfo;
4135
}
42-
43-
/* (non-Javadoc)
44-
* @see de.catma.document.source.contenthandler.SourceContentHandler#getSourceDocumentInfo()
45-
*/
46-
public SourceDocumentInfo getSourceDocumentInfo() {
36+
37+
@Override
38+
public SourceDocumentInfo getSourceDocumentInfo() {
4739
return sourceDocumentInfo;
4840
}
4941

50-
/**
51-
* Does lazy loading, first call will lead to a {@link #load()}.
52-
*
53-
* @see de.catma.document.source.contenthandler.SourceContentHandler#getContent()
54-
*/
42+
@Override
5543
public String getContent() throws IOException {
5644
if (content == null) {
5745
load();
@@ -60,29 +48,26 @@ public String getContent() throws IOException {
6048
}
6149

6250
/**
63-
* @param content the content of the {@link de.catma.document.source.SourceDocument}. To be used
64-
* by concrete implementations.
51+
* To be used by concrete implementations to set the content.
52+
*
53+
* @param content the entire document text
6554
*/
6655
protected void setContent(String content) {
6756
this.content = content;
6857
}
69-
70-
/* (non-Javadoc)
71-
* @see de.catma.document.source.contenthandler.SourceContentHandler#unload()
72-
*/
58+
59+
@Override
7360
public void unload() {
7461
content = null;
7562
}
7663

77-
/* (non-Javadoc)
78-
* @see de.catma.document.source.contenthandler.SourceContentHandler#isLoaded()
79-
*/
80-
public boolean isLoaded() {
81-
return (content != null);
82-
}
83-
84-
@Override
85-
public boolean hasIntrinsicMarkupCollection() {
86-
return false;
87-
}
64+
@Override
65+
public boolean isLoaded() {
66+
return content != null;
67+
}
68+
69+
@Override
70+
public boolean hasIntrinsicAnnotationCollection() {
71+
return false;
72+
}
8873
}

src/main/java/de/catma/document/source/contenthandler/OldXMLContentHandler.java

-143
This file was deleted.

src/main/java/de/catma/document/source/contenthandler/SourceContentHandler.java

+43-35
Original file line numberDiff line numberDiff line change
@@ -18,62 +18,70 @@
1818
*/
1919
package de.catma.document.source.contenthandler;
2020

21-
import java.io.IOException;
22-
import java.io.InputStream;
23-
2421
import de.catma.document.source.FileType;
2522
import de.catma.document.source.SourceDocument;
2623
import de.catma.document.source.SourceDocumentInfo;
24+
import de.catma.document.source.TechInfoSet;
25+
26+
import java.io.IOException;
2727

2828
/**
29-
* A content handler for a source document. The content handler is responsible for
30-
* loading content from a source document and keeping it in memory.
29+
* A content handler for a {@link SourceDocument}. It is responsible for loading content from a source document and keeping it in memory.
3130
* <p>
3231
* It uses the proper encoding and {@link FileType}.
33-
* <p>
34-
* <strong>SourceContentHandler implementations need to have a default no-arg constructor!</strong>
3532
*/
3633
public interface SourceContentHandler {
37-
3834
/**
39-
* @param sourceDocumentInfo all the metadata for the {@link SourceDocument}, has
40-
* to be set right after instance creation completed
35+
* Sets all the metadata for the source document with which this instance is associated. Must be called immediately after instantiation.
36+
*
37+
* @param sourceDocumentInfo a {@link SourceDocumentInfo} object containing the metadata
4138
*/
42-
public void setSourceDocumentInfo(
43-
SourceDocumentInfo sourceDocumentInfo);
44-
39+
void setSourceDocumentInfo(SourceDocumentInfo sourceDocumentInfo);
40+
4541
/**
46-
* @return all the metadata for the {@link SourceDocument}
42+
* Returns all the metadata for the source document with which this instance is associated.
43+
*
44+
* @return a {@link SourceDocumentInfo} object containing the metadata
4745
*/
48-
public SourceDocumentInfo getSourceDocumentInfo();
49-
46+
SourceDocumentInfo getSourceDocumentInfo();
47+
5048
/**
51-
* @param is the {@link SourceDocument} as raw data.
52-
* @throws IOException error accessing the input stream.
49+
* Loads the content of the source document with which this instance is associated.
50+
* <p>
51+
* Loading is performed from the resource identified via {@link TechInfoSet#getURI()} of the {@link SourceDocumentInfo}.
52+
*
53+
* @throws IOException if an error occurs while loading the content
5354
*/
54-
public void load(InputStream is) throws IOException;
55+
void load() throws IOException;
56+
5557
/**
56-
* Loading via {@link de.catma.document.source.TechInfoSet#getURI()} of the {@link SourceDocumentInfo}.
57-
* @throws IOException error accessing {@link de.catma.document.source.TechInfoSet#getURI()}.
58+
* Returns the content of the source document with which this instance is associated.
59+
*
60+
* @return the entire document text
61+
* @throws IOException if an error occurs while loading the content
5862
*/
59-
public void load() throws IOException;
60-
63+
String getContent() throws IOException;
64+
6165
/**
62-
* @return the extracted text of the {@link SourceDocument}.
63-
* @throws IOException
66+
* Discards the content of the source document with which this instance is associated.
6467
*/
65-
public String getContent() throws IOException;
66-
68+
void unload();
69+
6770
/**
68-
* Discards the content.
71+
* Whether the content of the source document with which this instance is associated has been loaded.
72+
*
73+
* @return <code>true</code> if the content has been loaded, <code>false</code> if the content has not yet been loaded or was unloaded via
74+
* {@link SourceContentHandler#unload()}
6975
*/
70-
public void unload();
71-
76+
boolean isLoaded();
77+
7278
/**
73-
* @return <code>true</code> if the content has been loaded and not yet unloaded, else <code>false</code>.
79+
* Whether the source document with which this instance is associated contains embedded annotations.
80+
* <p>
81+
* Can only be true for XML documents.
82+
*
83+
* @return <code>true</code> if embedded annotations exist, otherwise <code>false</code>
7484
*/
75-
public boolean isLoaded();
76-
77-
public boolean hasIntrinsicMarkupCollection();
78-
85+
@Deprecated
86+
boolean hasIntrinsicAnnotationCollection();
7987
}

0 commit comments

Comments
 (0)