public void write(DataOutput out, Token token) throws IOException { long id = token.getId(); byte idType; if (id <= Byte.MAX_VALUE - Byte.MIN_VALUE) { idType = ID_ONE_BYTE; } else if (id <= Short.MAX_VALUE - Short.MIN_VALUE) { idType = ID_TWO_BYTES; } else if (id <= (long) Integer.MAX_VALUE - (long) Integer.MIN_VALUE) { // cast to long to prevent overflow idType = ID_FOUR_BYTES; } else { idType = ID_EIGHT_BYTES; } out.write(token.getType() + idType); token.writeTo(out, idType); }
private Token readToken() { if (pushback == null) { try { Token token = tokenFormatter.read(in); switch (token.getType()) { case Token.TYPE_MAP_ID_TO_VALUE: idRegistry.put(token.getId(), token.getValue()); return readToken(); // Next one please. default: return token; } } catch (IOException e) { throw new StreamException(e); } } else { Token result = pushback; pushback = null; return result; } }
public void moveDown() { depthState.push(); Token firstToken = readToken(); switch (firstToken.getType()) { case Token.TYPE_START_NODE: depthState.setName(idRegistry.get(firstToken.getId())); switch (nextToken.getType()) { case Token.TYPE_ATTRIBUTE: depthState.addAttribute(idRegistry.get(nextToken.getId()), nextToken.getValue());
public void write(DataOutput out, Token token) throws IOException { long id = token.getId(); byte idType; if (id <= Byte.MAX_VALUE - Byte.MIN_VALUE) { idType = ID_ONE_BYTE; } else if (id <= Short.MAX_VALUE - Short.MIN_VALUE) { idType = ID_TWO_BYTES; } else if (id <= (long) Integer.MAX_VALUE - (long) Integer.MIN_VALUE) { // cast to long to prevent overflow idType = ID_FOUR_BYTES; } else { idType = ID_EIGHT_BYTES; } out.write(token.getType() + idType); token.writeTo(out, idType); }
public void write(final DataOutput out, final Token token) throws IOException { final long id = token.getId(); byte idType; if (id <= Byte.MAX_VALUE - Byte.MIN_VALUE) { idType = ID_ONE_BYTE; } else if (id <= Short.MAX_VALUE - Short.MIN_VALUE) { idType = ID_TWO_BYTES; } else if (id <= (long)Integer.MAX_VALUE - (long)Integer.MIN_VALUE) { // cast to long to prevent overflow idType = ID_FOUR_BYTES; } else { idType = ID_EIGHT_BYTES; } out.write(token.getType() + idType); token.writeTo(out, idType); }
public void write(DataOutput out, Token token) throws IOException { long id = token.getId(); byte idType; if (id <= Byte.MAX_VALUE - Byte.MIN_VALUE) { idType = ID_ONE_BYTE; } else if (id <= Short.MAX_VALUE - Short.MIN_VALUE) { idType = ID_TWO_BYTES; } else if (id <= (long) Integer.MAX_VALUE - (long) Integer.MIN_VALUE) { // cast to long to prevent overflo idType = ID_FOUR_BYTES; } else { idType = ID_EIGHT_BYTES; } out.write(token.getType() + idType); token.writeTo(out, idType); }
public void write(DataOutput out, Token token) throws IOException { long id = token.getId(); byte idType; if (id <= Byte.MAX_VALUE - Byte.MIN_VALUE) { idType = ID_ONE_BYTE; } else if (id <= Short.MAX_VALUE - Short.MIN_VALUE) { idType = ID_TWO_BYTES; } else if (id <= (long) Integer.MAX_VALUE - (long) Integer.MIN_VALUE) { // cast to long to prevent overflow idType = ID_FOUR_BYTES; } else { idType = ID_EIGHT_BYTES; } out.write(token.getType() + idType); token.writeTo(out, idType); }
public void write(DataOutput out, Token token) throws IOException { long id = token.getId(); byte idType; if (id <= Byte.MAX_VALUE - Byte.MIN_VALUE) { idType = ID_ONE_BYTE; } else if (id <= Short.MAX_VALUE - Short.MIN_VALUE) { idType = ID_TWO_BYTES; } else if (id <= (long) Integer.MAX_VALUE - (long) Integer.MIN_VALUE) { // cast to long to prevent overflow idType = ID_FOUR_BYTES; } else { idType = ID_EIGHT_BYTES; } out.write(token.getType() + idType); token.writeTo(out, idType); }
public void write(DataOutput out, Token token) throws IOException { long id = token.getId(); byte idType; if (id <= Byte.MAX_VALUE - Byte.MIN_VALUE) { idType = ID_ONE_BYTE; } else if (id <= Short.MAX_VALUE - Short.MIN_VALUE) { idType = ID_TWO_BYTES; } else if (id <= (long) Integer.MAX_VALUE - (long) Integer.MIN_VALUE) { // cast to long to prevent overflow idType = ID_FOUR_BYTES; } else { idType = ID_EIGHT_BYTES; } out.write(token.getType() + idType); token.writeTo(out, idType); }
public void write(DataOutput out, Token token) throws IOException { long id = token.getId(); byte idType; if (id <= Byte.MAX_VALUE - Byte.MIN_VALUE) { idType = ID_ONE_BYTE; } else if (id <= Short.MAX_VALUE - Short.MIN_VALUE) { idType = ID_TWO_BYTES; } else if (id <= (long) Integer.MAX_VALUE - (long) Integer.MIN_VALUE) { // cast to long to prevent overflo idType = ID_FOUR_BYTES; } else { idType = ID_EIGHT_BYTES; } out.write(token.getType() + idType); token.writeTo(out, idType); }
public void write(DataOutput out, Token token) throws IOException { long id = token.getId(); byte idType; if (id <= Byte.MAX_VALUE - Byte.MIN_VALUE) { idType = ID_ONE_BYTE; } else if (id <= Short.MAX_VALUE - Short.MIN_VALUE) { idType = ID_TWO_BYTES; } else if (id <= (long) Integer.MAX_VALUE - (long) Integer.MIN_VALUE) { // cast to long to prevent overflow idType = ID_FOUR_BYTES; } else { idType = ID_EIGHT_BYTES; } out.write(token.getType() + idType); token.writeTo(out, idType); }
public String peekNextChild() { Token nextToken = readToken(); switch (nextToken.getType()) { case Token.TYPE_VALUE: case Token.TYPE_END_NODE: pushBack(nextToken); return null; case Token.TYPE_START_NODE: pushBack(nextToken); return idRegistry.get(nextToken.getId()); default: throw new StreamException("Unexpected token " + nextToken); } }
private Token readToken() { if (pushback == null) { try { Token token = tokenFormatter.read(in); switch (token.getType()) { case Token.TYPE_MAP_ID_TO_VALUE: idRegistry.put(token.getId(), token.getValue()); return readToken(); // Next one please. default: return token; } } catch (IOException e) { throw new StreamException(e); } } else { Token result = pushback; pushback = null; return result; } }
private Token readToken() { if (pushback == null) { try { Token token = tokenFormatter.read(in); switch (token.getType()) { case Token.TYPE_MAP_ID_TO_VALUE: idRegistry.put(token.getId(), token.getValue()); return readToken(); // Next one please. default: return token; } } catch (IOException e) { throw new StreamException(e); } } else { Token result = pushback; pushback = null; return result; } }
private Token readToken() { if (pushback == null) { try { Token token = tokenFormatter.read(in); switch (token.getType()) { case Token.TYPE_MAP_ID_TO_VALUE: idRegistry.put(token.getId(), token.getValue()); return readToken(); // Next one please. default: return token; } } catch (IOException e) { throw new StreamException(e); } } else { Token result = pushback; pushback = null; return result; } }
private Token readToken() { if (pushback == null) { try { final Token token = tokenFormatter.read(in); switch (token.getType()) { case Token.TYPE_MAP_ID_TO_VALUE: idRegistry.put(token.getId(), token.getValue()); return readToken(); // Next one please. default: return token; } } catch (final IOException e) { throw new StreamException(e); } } else { final Token result = pushback; pushback = null; return result; } }
private Token readToken() { if (pushback == null) { try { Token token = tokenFormatter.read(in); switch (token.getType()) { case Token.TYPE_MAP_ID_TO_VALUE: idRegistry.put(token.getId(), token.getValue()); return readToken(); // Next one please. default: return token; } } catch (IOException e) { throw new StreamException(e); } } else { Token result = pushback; pushback = null; return result; } }
private Token readToken() { if (pushback == null) { try { Token token = tokenFormatter.read(in); switch (token.getType()) { case Token.TYPE_MAP_ID_TO_VALUE: idRegistry.put(token.getId(), token.getValue()); return readToken(); // Next one please. default: return token; } } catch (IOException e) { throw new StreamException(e); } } else { Token result = pushback; pushback = null; return result; } }
private Token readToken() { if (pushback == null) { try { Token token = tokenFormatter.read(in); switch (token.getType()) { case Token.TYPE_MAP_ID_TO_VALUE: idRegistry.put(token.getId(), token.getValue()); return readToken(); // Next one please. default: return token; } } catch (IOException e) { throw new StreamException(e); } } else { Token result = pushback; pushback = null; return result; } }