LUCENE-1825: Additional incorrect getAttribute usage

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@806986 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2009-08-23 16:17:08 +00:00
parent 6847c0e2bd
commit c2f95d474b
2 changed files with 9 additions and 15 deletions

View File

@ -51,17 +51,15 @@ public class DateRecognizerSinkFilter extends SinkFilter {
public boolean accept(AttributeSource source) { public boolean accept(AttributeSource source) {
if (termAtt == null) { if (termAtt == null) {
termAtt = (TermAttribute) source.getAttribute(TermAttribute.class); termAtt = (TermAttribute) source.addAttribute(TermAttribute.class);
} }
if (termAtt != null) { try {
try { Date date = dateFormat.parse(termAtt.term());//We don't care about the date, just that we can parse it as a date
Date date = dateFormat.parse(termAtt.term());//We don't care about the date, just that we can parse it as a date if (date != null) {
if (date != null) { return true;
return true;
}
} catch (ParseException e) {
} }
} catch (ParseException e) {
} }
return false; return false;

View File

@ -31,15 +31,11 @@ public class TokenTypeSinkFilter extends SinkFilter {
public boolean accept(AttributeSource source) { public boolean accept(AttributeSource source) {
if (typeAtt == null) { if (typeAtt == null) {
typeAtt = (TypeAttribute) source.getAttribute(TypeAttribute.class); typeAtt = (TypeAttribute) source.addAttribute(TypeAttribute.class);
} }
//check to see if this is a Category //check to see if this is a Category
if (typeAtt != null && typeToMatch.equals(typeAtt.type())){ return (typeToMatch.equals(typeAtt.type()));
return true;
}
return false;
} }
} }