Skip to content

Commit

Permalink
refactor: rename *_RETAIN_GENERAL_ENTITIES parameter to *_RETAIN_ATTR…
Browse files Browse the repository at this point in the history
…IBUTE_GENERAL_ENTITIES

solve possible NullPointerException when referencing P_RETAIN_ATTRIBUTE_GENERAL_ENTITIES property

Refs: FasterXML#65
  • Loading branch information
cjmamo committed Apr 5, 2021
1 parent 083c2f4 commit e868edc
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/fasterxml/aalto/AaltoInputProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
public final class AaltoInputProperties {

/**
* Feature controlling whether general entities are retained.
* Feature controlling whether general entities in attributes are retained.
*
* @since 1.3
*/
public final static String P_RETAIN_GENERAL_ENTITIES = "com.fasterxml.aalto.retainGeneralEntities";
public final static String P_RETAIN_ATTRIBUTE_GENERAL_ENTITIES = "com.fasterxml.aalto.retainAttributeGeneralEntities";
}
10 changes: 5 additions & 5 deletions src/main/java/com/fasterxml/aalto/in/ReaderConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public final class ReaderConfig
final static int F_AUTO_CLOSE_INPUT = 0x2000;

// Custom flags:
final static int F_RETAIN_GENERAL_ENTITIES = 0x4000;
final static int F_RETAIN_ATTRIBUTE_GENERAL_ENTITIES = 0x4000;

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

// Custom ones
sProperties.put(AaltoInputProperties.P_RETAIN_GENERAL_ENTITIES, Integer.valueOf(F_RETAIN_GENERAL_ENTITIES));
sProperties.put(AaltoInputProperties.P_RETAIN_ATTRIBUTE_GENERAL_ENTITIES, Integer.valueOf(F_RETAIN_ATTRIBUTE_GENERAL_ENTITIES));
}

/**
Expand Down Expand Up @@ -283,8 +283,8 @@ public void doReportCData(boolean state) {
setFlag(F_REPORT_CDATA, state);
}

public void doRetainGeneralEntities(boolean state) {
setFlag(F_RETAIN_GENERAL_ENTITIES, state);
public void doRetainAttributeGeneralEntities(boolean state) {
setFlag(F_RETAIN_ATTRIBUTE_GENERAL_ENTITIES, state);
}

/*
Expand Down Expand Up @@ -421,7 +421,7 @@ public boolean willParseLazily() {

// // // Custom properties

public boolean willRetainGeneralEntities() { return hasFlag(F_RETAIN_GENERAL_ENTITIES); }
public boolean willRetainAttributeGeneralEntities() { return hasFlag(F_RETAIN_ATTRIBUTE_GENERAL_ENTITIES); }

/*
/**********************************************************************
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/fasterxml/aalto/in/ReaderScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ protected final int handleStartElement(char c)
* simplify main method, which makes code more maintainable
* and possibly easier for JIT/HotSpot to optimize.
*/
private final int collectValue(int attrPtr, char quoteChar, PName attrName)
private int collectValue(int attrPtr, char quoteChar, PName attrName)
throws XMLStreamException
{
char[] attrBuffer = _attrCollector.startNewValue(attrName, attrPtr);
Expand Down Expand Up @@ -896,7 +896,7 @@ private final int collectValue(int attrPtr, char quoteChar, PName attrName)
throwUnexpectedChar(c, "'<' not allowed in attribute value");
case XmlCharTypes.CT_AMP:
{
if (!_config.willRetainGeneralEntities()) {
if (!_config.willRetainAttributeGeneralEntities()) {
int d = handleEntityInText(false);
if (d == 0) { // unexpanded general entity... not good
reportUnexpandedEntityInAttr(attrName, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public boolean getFeature(String name)
case IS_STANDALONE: // read-only, but only during parsing
return true;
case EXTERNAL_GENERAL_ENTITIES:
return !((Boolean) mStaxFactory.getProperty(AaltoInputProperties.P_RETAIN_GENERAL_ENTITIES)).booleanValue();
return Boolean.FALSE.equals(mStaxFactory.getProperty(AaltoInputProperties.P_RETAIN_ATTRIBUTE_GENERAL_ENTITIES));
default:
}
} else {
Expand Down Expand Up @@ -98,7 +98,7 @@ public void setFeature(String name, boolean enabled)

switch (stdFeat) {
case EXTERNAL_GENERAL_ENTITIES:
mStaxFactory.setProperty(AaltoInputProperties.P_RETAIN_GENERAL_ENTITIES, !enabled);
mStaxFactory.setProperty(AaltoInputProperties.P_RETAIN_ATTRIBUTE_GENERAL_ENTITIES, !enabled);
ok = true;
break;
case EXTERNAL_PARAMETER_ENTITIES:
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/fasterxml/aalto/sax/SAXParserImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public boolean getFeature(String name)
// !!! TBI
return true;
case EXTERNAL_GENERAL_ENTITIES:
return !((Boolean) _staxFactory.getProperty(AaltoInputProperties.P_RETAIN_GENERAL_ENTITIES)).booleanValue();
return Boolean.FALSE.equals(_staxFactory.getProperty(AaltoInputProperties.P_RETAIN_ATTRIBUTE_GENERAL_ENTITIES));
default:
}
} else {
Expand Down

0 comments on commit e868edc

Please sign in to comment.