Skip to content

Commit

Permalink
Added @OverRide annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
car031 committed May 25, 2023
1 parent 894563e commit 804b853
Show file tree
Hide file tree
Showing 64 changed files with 288 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public enum DocumentEvent {
this.event = event;
}

@Override
public String toString() {
return this.event;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,12 @@ public void setFolderName(String folderName) {
this.folderName = folderName;
}

@Override
public Long getTemplateId() {
return templateId;
}

@Override
public void setTemplateId(Long templateId) {
this.templateId = templateId;
}
Expand Down Expand Up @@ -277,18 +279,22 @@ public void setEvent(String event) {
this.event = event;
}

@Override
public String getCreator() {
return creator;
}

@Override
public void setCreator(String creator) {
this.creator = creator;
}

@Override
public long getCreatorId() {
return creatorId;
}

@Override
public void setCreatorId(long creatorId) {
this.creatorId = creatorId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -813,14 +813,13 @@ public List<Document> findDeletedDocs() throws PersistenceException {

@SuppressWarnings("rawtypes")
RowMapper docMapper = new BeanPropertyRowMapper() {
@Override
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {

Document doc = new Document();
doc.setId(rs.getLong(1));
doc.setCustomId(rs.getString(2));
doc.setLastModified(rs.getDate(3));
doc.setFileName(rs.getString(4));

return doc;
}
};
Expand Down Expand Up @@ -910,6 +909,7 @@ public void makeImmutable(long docId, DocumentHistory transaction) throws Persis
store(doc, transaction);
}

@Override
public void deleteAll(Collection<Document> documents, DocumentHistory transaction) throws PersistenceException {
deleteAll(documents, PersistentObject.DELETED_CODE_DEFAULT, transaction);
}
Expand Down Expand Up @@ -993,6 +993,7 @@ public List<Document> findDeleted(long userId, Integer maxHits) throws Persisten

@SuppressWarnings("rawtypes")
RowMapper docMapper = new BeanPropertyRowMapper() {
@Override
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
Document doc = new Document();
doc.setId(rs.getLong(1));
Expand Down Expand Up @@ -1104,7 +1105,8 @@ public void cleanUnexistingUniqueTags() throws PersistenceException {

// tags no more existing in the ld_tag table or that belong to
// deleted documents
deleteStatement.append(" ld_uniquetag.ld_tag NOT IN ( SELECT DISTINCT t.ld_tag FROM ld_tag t JOIN ld_document d ON d.ld_id = t.ld_docid WHERE ld_uniquetag.ld_tenantid = t.ld_tenantid AND ld_uniquetag.ld_tag = t.ld_tag AND d.ld_deleted = 0 ) ");
deleteStatement.append(
" ld_uniquetag.ld_tag NOT IN ( SELECT DISTINCT t.ld_tag FROM ld_tag t JOIN ld_document d ON d.ld_id = t.ld_docid WHERE ld_uniquetag.ld_tenantid = t.ld_tenantid AND ld_uniquetag.ld_tag = t.ld_tag AND d.ld_deleted = 0 ) ");

// tags no more existing in the ld_foldertag table or that belong to
// deleted folders
Expand Down Expand Up @@ -1330,6 +1332,7 @@ public Document findByPath(String path, long tenantId) throws PersistenceExcepti
return null;
}

@SuppressWarnings("unchecked")
@Override
public List<String> findDuplicatedDigests(Long tenantId, Long folderId) throws PersistenceException {
// First of all, find all duplicates digests.
Expand All @@ -1349,10 +1352,8 @@ public List<String> findDuplicatedDigests(Long tenantId, Long folderId) throws P
}
digestQuery.append(" and ld_docref is null and ld_digest is not null group by ld_digest having count(*) > 1");

return query(digestQuery.toString(), null, new RowMapper<String>() {
public String mapRow(ResultSet rs, int rowNum) throws SQLException {
return rs.getString(1);
}
return query(digestQuery.toString(), null, (rs, rowNum) -> {
return rs.getString(1);
}, null);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public Rating findVotesByDocId(long docId) {

@SuppressWarnings("rawtypes")
RowMapper ratingMapper = new BeanPropertyRowMapper() {
@Override
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {

Rating rating = new Rating();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ public boolean isAlias() {
return type == TYPE_ALIAS;
}

@Override
public long getId() {
return id;
}
Expand All @@ -235,6 +236,7 @@ public void clearFolderGroups() {
folderGroups = new HashSet<>();
}

@Override
public void setId(long id) {
this.id = id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public enum FolderEvent {
this.event = event;
}

@Override
public String toString() {
return this.event;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,23 @@ public String getContent() {
return tmp;
}


@Override
public void startElement(String namespaceURI, String localName, String rawName, Attributes atts)
throws SAXException {
if (rawName.startsWith("p")) {
appendChar = true;
}
}

@Override
public void characters(char[] ch, int start, int length) throws SAXException {
if (appendChar) {
content.append(ch, start, length).append(" ");
}
}

@Override
public void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
throws SAXException {
appendChar = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,127 +10,128 @@
import org.xml.sax.helpers.DefaultHandler;

/**
* Utility class for extracting text content from an XML document.
* An instance of this class is a SAX event handler that extracts
* character data and attribute values from the SAX events and writes
* the extracted content to a given {@link Writer}.
* Utility class for extracting text content from an XML document. An instance
* of this class is a SAX event handler that extracts character data and
* attribute values from the SAX events and writes the extracted content to a
* given {@link Writer}.
* <p>
* Any whitespace sequences are imploded into a single space character
* and consecutive attribute values and character data are delimited
* using spaces.
* Any whitespace sequences are imploded into a single space character and
* consecutive attribute values and character data are delimited using spaces.
* <p>
* This class also implements the {@link ErrorHandler} interface by
* ignoring all errors and warnings. This is useful in avoiding the
* default console output or other error logging of many XML parsers.
* This class also implements the {@link ErrorHandler} interface by ignoring all
* errors and warnings. This is useful in avoiding the default console output or
* other error logging of many XML parsers.
*
* @see XMLParser
* @since 4.5.2
*/
class ExtractorHandler extends DefaultHandler implements ErrorHandler {

/**
* Separator that is written between consecutive text and attribute values.
*/
private static final char SPACE_CHAR = ' ';
/**
* Separator that is written between consecutive text and attribute values.
*/
private static final char SPACE_CHAR = ' ';

/**
* The writer to which the selected text content is written.
*/
private final Writer writer;
/**
* The writer to which the selected text content is written.
*/
private final Writer writer;

/**
* Flag for outputting a space before the next character to be outputted.
* Used to implode all whitespace sequences and to separate consecutive
* attribute values and text elements.
*/
private boolean space;
/**
* Flag for outputting a space before the next character to be outputted.
* Used to implode all whitespace sequences and to separate consecutive
* attribute values and text elements.
*/
private boolean space;

/**
* Creates an extractor handler that writes text content to the given
* writer.
*
* @param writer writer to which the XML text content is written
*/
public ExtractorHandler(Writer writer) {
this.writer = writer;
this.space = false;
}
/**
* Creates an extractor handler that writes text content to the given
* writer.
*
* @param writer writer to which the XML text content is written
*/
public ExtractorHandler(Writer writer) {
this.writer = writer;
this.space = false;
}

//------------------------------------------------------< DefaultHandler >
// ------------------------------------------------------< DefaultHandler >

/**
* Writes attribute values to the underlying writer.
*
* @param uri ignored
* @param local ignored
* @param name ignored
* @param attributes attributes, whose values to extract
* @throws SAXException on IO errors
*/
public void startElement(
String uri, String local, String name, Attributes attributes)
throws SAXException {
for (int i = 0; i < attributes.getLength(); i++) {
String value = attributes.getValue(i);
characters(value.toCharArray(), 0, value.length());
}
}
/**
* Writes attribute values to the underlying writer.
*
* @param uri ignored
* @param local ignored
* @param name ignored
* @param attributes attributes, whose values to extract
* @throws SAXException on IO errors
*/
@Override
public void startElement(String uri, String local, String name, Attributes attributes) throws SAXException {
for (int i = 0; i < attributes.getLength(); i++) {
String value = attributes.getValue(i);
characters(value.toCharArray(), 0, value.length());
}
}

/**
* Writes the given characters to the underlying writer.
*
* @param ch character array that contains the characters to be written
* @param start start index within the array
* @param length number of characters to write
* @throws SAXException on IO errors
*/
public void characters(char[] ch, int start, int length)
throws SAXException {
try {
for (int i = 0; i < length; i++) {
if (Character.isSpaceChar(ch[start + i])) {
space = true;
} else {
if (space) {
writer.write(SPACE_CHAR);
space = false;
}
writer.write(ch[start + i]);
}
}
space = true;
} catch (IOException e) {
throw new SAXException(e.getMessage());
}
}
/**
* Writes the given characters to the underlying writer.
*
* @param ch character array that contains the characters to be written
* @param start start index within the array
* @param length number of characters to write
* @throws SAXException on IO errors
*/
@Override
public void characters(char[] ch, int start, int length) throws SAXException {
try {
for (int i = 0; i < length; i++) {
if (Character.isSpaceChar(ch[start + i])) {
space = true;
} else {
if (space) {
writer.write(SPACE_CHAR);
space = false;
}
writer.write(ch[start + i]);
}
}
space = true;
} catch (IOException e) {
throw new SAXException(e.getMessage());
}
}

//--------------------------------------------------------< ErrorHandler >
// --------------------------------------------------------< ErrorHandler >

/**
* Ignored.
*
* @param exception ignored
*/
public void warning(SAXParseException exception) {
// Noting to do
}
/**
* Ignored.
*
* @param exception ignored
*/
@Override
public void warning(SAXParseException exception) {
// Noting to do
}

/**
* Ignored.
*
* @param exception ignored
*/
public void error(SAXParseException exception) {
// Noting to do
}
/**
* Ignored.
*
* @param exception ignored
*/
@Override
public void error(SAXParseException exception) {
// Noting to do
}

/**
* Ignored.
*
* @param exception ignored
*/
public void fatalError(SAXParseException exception) {
// Noting to do
}
/**
* Ignored.
*
* @param exception ignored
*/
@Override
public void fatalError(SAXParseException exception) {
// Noting to do
}

}
Loading

0 comments on commit 804b853

Please sign in to comment.