Skip to content

Commit e868edc

Browse files
committed
refactor: rename *_RETAIN_GENERAL_ENTITIES parameter to *_RETAIN_ATTRIBUTE_GENERAL_ENTITIES
solve possible NullPointerException when referencing P_RETAIN_ATTRIBUTE_GENERAL_ENTITIES property Refs: FasterXML#65
1 parent 083c2f4 commit e868edc

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

src/main/java/com/fasterxml/aalto/AaltoInputProperties.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
public final class AaltoInputProperties {
99

1010
/**
11-
* Feature controlling whether general entities are retained.
11+
* Feature controlling whether general entities in attributes are retained.
1212
*
1313
* @since 1.3
1414
*/
15-
public final static String P_RETAIN_GENERAL_ENTITIES = "com.fasterxml.aalto.retainGeneralEntities";
15+
public final static String P_RETAIN_ATTRIBUTE_GENERAL_ENTITIES = "com.fasterxml.aalto.retainAttributeGeneralEntities";
1616
}

src/main/java/com/fasterxml/aalto/in/ReaderConfig.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public final class ReaderConfig
4242
final static int F_AUTO_CLOSE_INPUT = 0x2000;
4343

4444
// Custom flags:
45-
final static int F_RETAIN_GENERAL_ENTITIES = 0x4000;
45+
final static int F_RETAIN_ATTRIBUTE_GENERAL_ENTITIES = 0x4000;
4646

4747
/**
4848
* These are the default settings for XMLInputFactory.
@@ -101,7 +101,7 @@ public final class ReaderConfig
101101
sProperties.put(XMLInputFactory2.P_DTD_OVERRIDE, null);
102102

103103
// Custom ones
104-
sProperties.put(AaltoInputProperties.P_RETAIN_GENERAL_ENTITIES, Integer.valueOf(F_RETAIN_GENERAL_ENTITIES));
104+
sProperties.put(AaltoInputProperties.P_RETAIN_ATTRIBUTE_GENERAL_ENTITIES, Integer.valueOf(F_RETAIN_ATTRIBUTE_GENERAL_ENTITIES));
105105
}
106106

107107
/**
@@ -283,8 +283,8 @@ public void doReportCData(boolean state) {
283283
setFlag(F_REPORT_CDATA, state);
284284
}
285285

286-
public void doRetainGeneralEntities(boolean state) {
287-
setFlag(F_RETAIN_GENERAL_ENTITIES, state);
286+
public void doRetainAttributeGeneralEntities(boolean state) {
287+
setFlag(F_RETAIN_ATTRIBUTE_GENERAL_ENTITIES, state);
288288
}
289289

290290
/*
@@ -421,7 +421,7 @@ public boolean willParseLazily() {
421421

422422
// // // Custom properties
423423

424-
public boolean willRetainGeneralEntities() { return hasFlag(F_RETAIN_GENERAL_ENTITIES); }
424+
public boolean willRetainAttributeGeneralEntities() { return hasFlag(F_RETAIN_ATTRIBUTE_GENERAL_ENTITIES); }
425425

426426
/*
427427
/**********************************************************************

src/main/java/com/fasterxml/aalto/in/ReaderScanner.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ protected final int handleStartElement(char c)
830830
* simplify main method, which makes code more maintainable
831831
* and possibly easier for JIT/HotSpot to optimize.
832832
*/
833-
private final int collectValue(int attrPtr, char quoteChar, PName attrName)
833+
private int collectValue(int attrPtr, char quoteChar, PName attrName)
834834
throws XMLStreamException
835835
{
836836
char[] attrBuffer = _attrCollector.startNewValue(attrName, attrPtr);
@@ -896,7 +896,7 @@ private final int collectValue(int attrPtr, char quoteChar, PName attrName)
896896
throwUnexpectedChar(c, "'<' not allowed in attribute value");
897897
case XmlCharTypes.CT_AMP:
898898
{
899-
if (!_config.willRetainGeneralEntities()) {
899+
if (!_config.willRetainAttributeGeneralEntities()) {
900900
int d = handleEntityInText(false);
901901
if (d == 0) { // unexpanded general entity... not good
902902
reportUnexpandedEntityInAttr(attrName, false);

src/main/java/com/fasterxml/aalto/sax/SAXParserFactoryImpl.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public boolean getFeature(String name)
7070
case IS_STANDALONE: // read-only, but only during parsing
7171
return true;
7272
case EXTERNAL_GENERAL_ENTITIES:
73-
return !((Boolean) mStaxFactory.getProperty(AaltoInputProperties.P_RETAIN_GENERAL_ENTITIES)).booleanValue();
73+
return Boolean.FALSE.equals(mStaxFactory.getProperty(AaltoInputProperties.P_RETAIN_ATTRIBUTE_GENERAL_ENTITIES));
7474
default:
7575
}
7676
} else {
@@ -98,7 +98,7 @@ public void setFeature(String name, boolean enabled)
9898

9999
switch (stdFeat) {
100100
case EXTERNAL_GENERAL_ENTITIES:
101-
mStaxFactory.setProperty(AaltoInputProperties.P_RETAIN_GENERAL_ENTITIES, !enabled);
101+
mStaxFactory.setProperty(AaltoInputProperties.P_RETAIN_ATTRIBUTE_GENERAL_ENTITIES, !enabled);
102102
ok = true;
103103
break;
104104
case EXTERNAL_PARAMETER_ENTITIES:

src/main/java/com/fasterxml/aalto/sax/SAXParserImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public boolean getFeature(String name)
264264
// !!! TBI
265265
return true;
266266
case EXTERNAL_GENERAL_ENTITIES:
267-
return !((Boolean) _staxFactory.getProperty(AaltoInputProperties.P_RETAIN_GENERAL_ENTITIES)).booleanValue();
267+
return Boolean.FALSE.equals(_staxFactory.getProperty(AaltoInputProperties.P_RETAIN_ATTRIBUTE_GENERAL_ENTITIES));
268268
default:
269269
}
270270
} else {

0 commit comments

Comments
 (0)