private void readEntityDeclaration() throws IOException, XmlPullParserException {
  read(START_ENTITY);
  boolean generalEntity=true;
  skip();
  if (peekCharacter() == '%') {
    generalEntity=false;
    position++;
    skip();
  }
  String name=readName();
  skip();
  int quote=peekCharacter();
  String entityValue;
  if (quote == '"' || quote == '\'') {
    position++;
    entityValue=readValue((char)quote,true,false,ValueContext.ENTITY_DECLARATION);
    if (peekCharacter() == quote) {
      position++;
    }
  }
 else   if (readExternalId(true,false)) {
    entityValue="";
    skip();
    if (peekCharacter() == NDATA[0]) {
      read(NDATA);
      skip();
      readName();
    }
  }
 else {
    throw new XmlPullParserException("Expected entity value or external ID",this,null);
  }
  if (generalEntity && processDocDecl) {
    if (documentEntities == null) {
      documentEntities=new HashMap<String,char[]>();
    }
    documentEntities.put(name,entityValue.toCharArray());
  }
  skip();
  read('>');
}

private void readEntityDeclaration ( ) throws IOException , XmlPullParserException { read ( START_ENTITY ) ; boolean generalEntity = true ; skip ( ) ; if ( peekCharacter ( ) == '%' ) { generalEntity = false ; position ++ ; skip ( ) ; } String name = readName ( ) ; skip ( ) ; int quote = peekCharacter ( ) ; String entityValue ; if ( quote == '"' || quote == '\'' ) { position ++ ; entityValue = readValue ( ( char ) quote , true , false , ValueContext . ENTITY_DECLARATION ) ; if ( peekCharacter ( ) == quote ) { position ++ ; } } else if ( readExternalId ( true , false ) ) { entityValue = "" ; skip ( ) ; if ( peekCharacter ( ) == NDATA [ 0 ] ) { read ( NDATA ) ; skip ( ) ; readName ( ) ; } } else { throw new XmlPullParserException ( "Expected entity value or external ID" , this , null ) ; } if ( generalEntity && processDocDecl ) { if ( documentEntities == null ) { documentEntities = new HashMap < String , char [ ] > ( ) ; } documentEntities . put ( name , entityValue . toCharArray ( ) ) ; } skip ( ) ; read ( '>' ) ; }
read an entity declaration . the value of internal entities are inline : < ! entity foo " bar " > the values of external entities must be retrieved by url or path : < ! entity foo system " http : / / host / file " > < ! entity foo public " - / / android / / foo / / en " " http : / / host / file " > < ! entity foo system " . . / file . png " ndata png > entities may be general or parameterized . parameterized entities are marked by a percent sign . such entities may only be used in the dtd : < ! entity % foo " bar " >
