private static Tag readTagFromBuffer(BufferedReader br, boolean close) {
    int id = 0;
    String name = "", forceDescription = null;
    ArrayList<String> types = new ArrayList<>();
    String cardinality = "";
    String defaultValue = "";
    String typedef = null;
    String description = null;
    String[] valueCodes = null;
    String[] valueDescriptions = null;

    try {
      String sCurrentLine;
      boolean readingTypes = false;
      while ((sCurrentLine = br.readLine()) != null) {
        if (sCurrentLine.contains("\"id\"")) {
          String sid = sCurrentLine.substring(sCurrentLine.indexOf(":") + 1).replace(",", "").trim();
          id = Integer.parseInt(sid);
        } else if (sCurrentLine.contains("\"name\"")) {
          String sval = sCurrentLine.substring(sCurrentLine.indexOf(":") + 1).replace("\"", "").replace(",", "").trim();
          name = sval;
        } else if (sCurrentLine.contains("\"forceDescription\"")) {
          String sval = sCurrentLine.substring(sCurrentLine.indexOf(":") + 1).replace("\"", "").replace(",", "").trim();
          forceDescription = sval;
        } else if (sCurrentLine.contains("\"cardinality\"")) {
          String sval = sCurrentLine.substring(sCurrentLine.indexOf(":") + 1).replace("\"", "").replace(",", "").trim();
          cardinality = sval;
        } else if (sCurrentLine.contains("\"defaultValue\"")) {
          String sval = sCurrentLine.substring(sCurrentLine.indexOf(":") + 1).replace("\"", "").replace(",", "").trim();
          defaultValue = sval;
        } else if (sCurrentLine.contains("\"valueCodes\"")) {
          sCurrentLine = br.readLine();
          valueCodes = sCurrentLine.split(",");
        } else if (sCurrentLine.contains("\"description\"")) {
          description = sCurrentLine.substring(sCurrentLine.indexOf(":") + 1).replace("\"", "").replace(",", "").trim();
        } else if (sCurrentLine.contains("\"valueDescriptions\"")) {
          sCurrentLine = br.readLine();
          valueDescriptions = sCurrentLine.split(",");
        } else if (sCurrentLine.contains("\"typedef\"")) {
          String sval = sCurrentLine.substring(sCurrentLine.indexOf(":") + 1).replace("\"", "").replace(",", "").trim();
          typedef = sval;
        } else if (sCurrentLine.contains("\"type\"")) {
          readingTypes = true;
        } else if (sCurrentLine.contains("],")) {
          readingTypes = false;
        } else if (readingTypes) {
          String sval = sCurrentLine.replace("\"", "").replace(",", "").trim();
          types.add(sval);
        }
      }
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      try {
        //br.reset();
        if (br != null && close) br.close();
      } catch (IOException ex) {
        ex.printStackTrace();
      }
    }

    Tag tag = new Tag(id, name, types, cardinality, defaultValue, typedef, forceDescription);
    tag.setDescription(description);
    tag.createValuesDictionary();
    if (valueCodes != null && valueDescriptions != null && valueCodes.length == valueDescriptions.length) {
      HashMap<String, String> values = new HashMap<String, String>();
      for (int i=0;i<valueCodes.length;i++) {
        values.put(valueCodes[i].trim(), valueDescriptions[i].trim().replace("\"", ""));
      }
      tag.setValues(values);
    }

    tagMap.put(tag.getId(), tag);
    tagNames.put(tag.getName(), tag);
    return tag;
  }
private static Tag readTagFromBuffer ( BufferedReader br , boolean close ) { int id = 0 ; String name = "" , forceDescription = null ; ArrayList < String > types = new ArrayList < > ( ) ; String cardinality = "" ; String defaultValue = "" ; String typedef = null ; String description = null ; String [ ] valueCodes = null ; String [ ] valueDescriptions = null ; try { String sCurrentLine ; boolean readingTypes = false ; while ( ( sCurrentLine = br . readLine ( ) ) != null ) { if ( sCurrentLine . contains ( "\"id\"" ) ) { String sid = sCurrentLine . substring ( sCurrentLine . indexOf ( ":" ) + 1 ) . replace ( "," , "" ) . trim ( ) ; id = Integer . parseInt ( sid ) ; } else if ( sCurrentLine . contains ( "\"name\"" ) ) { String sval = sCurrentLine . substring ( sCurrentLine . indexOf ( ":" ) + 1 ) . replace ( "\"" , "" ) . replace ( "," , "" ) . trim ( ) ; name = sval ; } else if ( sCurrentLine . contains ( "\"forceDescription\"" ) ) { String sval = sCurrentLine . substring ( sCurrentLine . indexOf ( ":" ) + 1 ) . replace ( "\"" , "" ) . replace ( "," , "" ) . trim ( ) ; forceDescription = sval ; } else if ( sCurrentLine . contains ( "\"cardinality\"" ) ) { String sval = sCurrentLine . substring ( sCurrentLine . indexOf ( ":" ) + 1 ) . replace ( "\"" , "" ) . replace ( "," , "" ) . trim ( ) ; cardinality = sval ; } else if ( sCurrentLine . contains ( "\"defaultValue\"" ) ) { String sval = sCurrentLine . substring ( sCurrentLine . indexOf ( ":" ) + 1 ) . replace ( "\"" , "" ) . replace ( "," , "" ) . trim ( ) ; defaultValue = sval ; } else if ( sCurrentLine . contains ( "\"valueCodes\"" ) ) { sCurrentLine = br . readLine ( ) ; valueCodes = sCurrentLine . split ( "," ) ; } else if ( sCurrentLine . contains ( "\"description\"" ) ) { description = sCurrentLine . substring ( sCurrentLine . indexOf ( ":" ) + 1 ) . replace ( "\"" , "" ) . replace ( "," , "" ) . trim ( ) ; } else if ( sCurrentLine . contains ( "\"valueDescriptions\"" ) ) { sCurrentLine = br . readLine ( ) ; valueDescriptions = sCurrentLine . split ( "," ) ; } else if ( sCurrentLine . contains ( "\"typedef\"" ) ) { String sval = sCurrentLine . substring ( sCurrentLine . indexOf ( ":" ) + 1 ) . replace ( "\"" , "" ) . replace ( "," , "" ) . trim ( ) ; typedef = sval ; } else if ( sCurrentLine . contains ( "\"type\"" ) ) { readingTypes = true ; } else if ( sCurrentLine . contains ( "]," ) ) { readingTypes = false ; } else if ( readingTypes ) { String sval = sCurrentLine . replace ( "\"" , "" ) . replace ( "," , "" ) . trim ( ) ; types . add ( sval ) ; } } } catch ( IOException e ) { e . printStackTrace ( ) ; } finally { try { if ( br != null && close ) br . close ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; } } Tag tag = new Tag ( id , name , types , cardinality , defaultValue , typedef , forceDescription ) ; tag . setDescription ( description ) ; tag . createValuesDictionary ( ) ; if ( valueCodes != null && valueDescriptions != null && valueCodes . length == valueDescriptions . length ) { HashMap < String , String > values = new HashMap < String , String > ( ) ; for ( int i = 0 ; i < valueCodes . length ; i ++ ) { values . put ( valueCodes [ i ] . trim ( ) , valueDescriptions [ i ] . trim ( ) . replace ( "\"" , "" ) ) ; } tag . setValues ( values ) ; } tagMap . put ( tag . getId ( ) , tag ) ; tagNames . put ( tag . getName ( ) , tag ) ; return tag ; }
Read tag from buffer.

@param br the br
@return the tag