当前位置: 首页>>代码示例>>Java>>正文


Java Symbol类代码示例

本文整理汇总了Java中org.apache.avro.io.parsing.Symbol的典型用法代码示例。如果您正苦于以下问题:Java Symbol类的具体用法?Java Symbol怎么用?Java Symbol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Symbol类属于org.apache.avro.io.parsing包,在下文中一共展示了Symbol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readString

import org.apache.avro.io.parsing.Symbol; //导入依赖的package包/类
@Override
public String readString() throws IOException {
	advance(Symbol.STRING);
	if (parser.topSymbol() == Symbol.MAP_KEY_MARKER) {
		parser.advance(Symbol.MAP_KEY_MARKER);
		if (in.getCurrentToken() != JsonToken.FIELD_NAME) {
			throw error("map-key");
		}
	} else {
		if (in.getCurrentToken() != JsonToken.VALUE_STRING) {
			throw error("string");
		}
	}
	String result = in.getText();
	in.nextToken();
	return result;
}
 
开发者ID:Celos,项目名称:avro-json-decoder,代码行数:18,代码来源:ExtendedJsonDecoder.java

示例2: readEnum

import org.apache.avro.io.parsing.Symbol; //导入依赖的package包/类
@Override
public int readEnum() throws IOException {
	advance(Symbol.ENUM);
	Symbol.EnumLabelsAction top = (Symbol.EnumLabelsAction) parser.popSymbol();
	if (in.getCurrentToken() == JsonToken.VALUE_STRING) {
		in.getText();
		int n = top.findLabel(in.getText());
		if (n >= 0) {
			in.nextToken();
			return n;
		}
		throw new AvroTypeException("Unknown symbol in enum " + in.getText());
	} else {
		throw error("fixed");
	}
}
 
开发者ID:Celos,项目名称:avro-json-decoder,代码行数:17,代码来源:ExtendedJsonDecoder.java

示例3: readIndex

import org.apache.avro.io.parsing.Symbol; //导入依赖的package包/类
@Override
public int readIndex() throws IOException {
	advance(Symbol.UNION);
	Symbol.Alternative a = (Symbol.Alternative) parser.popSymbol();
	
	String label;
	if (in.getCurrentToken() == JsonToken.VALUE_NULL) {
		label = "null";
	} else if (in.getCurrentToken() == JsonToken.START_OBJECT &&
			in.nextToken() == JsonToken.FIELD_NAME) {
		label = in.getText();
		in.nextToken();
		parser.pushSymbol(Symbol.UNION_END);
	} else {
		throw error("start-union");
	}
	int n = a.findLabel(label);
	if (n < 0)
		throw new AvroTypeException("Unknown union branch " + label);
	parser.pushSymbol(a.getSymbol(n));
	return n;
}
 
开发者ID:Celos,项目名称:avro-json-decoder,代码行数:23,代码来源:ExtendedJsonDecoder.java

示例4: writeIndex

import org.apache.avro.io.parsing.Symbol; //导入依赖的package包/类
@Override
  public void writeIndex(int unionIndex) throws IOException {
    parser.advance(Symbol.UNION);
    Symbol.Alternative top = (Symbol.Alternative) parser.popSymbol();
    Symbol symbol = top.getSymbol(unionIndex);
    if(symbol != Symbol.NULL && isUnionOfNullWithSomething(top)){
//    	parser.pushSymbol(Symbol.UNION_END);
    	parser.pushSymbol(symbol);
    	return;
    }
    if (symbol != Symbol.NULL) {
      out.writeStartObject();
      out.writeFieldName(top.getLabel(unionIndex));
      parser.pushSymbol(Symbol.UNION_END);
    }
    parser.pushSymbol(symbol);
  }
 
开发者ID:openaire,项目名称:iis,代码行数:18,代码来源:HackedJsonEncoder.java

示例5: readString

import org.apache.avro.io.parsing.Symbol; //导入依赖的package包/类
@Override
public String readString() throws IOException {
  advance(Symbol.STRING);
  if (parser.topSymbol() == Symbol.MAP_KEY_MARKER) {
    parser.advance(Symbol.MAP_KEY_MARKER);
    if (in.getCurrentToken() != JsonToken.FIELD_NAME) {
      throw error("map-key");
    }
  } else {
    if (in.getCurrentToken() != JsonToken.VALUE_STRING) {
      throw error("string");
    }
  }
  String result = in.getText();
  in.nextToken();
  return result;
}
 
开发者ID:openaire,项目名称:iis,代码行数:18,代码来源:HackedJsonDecoder.java

示例6: readEnum

import org.apache.avro.io.parsing.Symbol; //导入依赖的package包/类
@Override
public int readEnum() throws IOException {
  advance(Symbol.ENUM);
  Symbol.EnumLabelsAction top = (Symbol.EnumLabelsAction) parser.popSymbol();
  if (in.getCurrentToken() == JsonToken.VALUE_STRING) {
    in.getText();
    int n = top.findLabel(in.getText());
    if (n >= 0) {
      in.nextToken();
      return n;
    }
    throw new AvroTypeException("Unknown symbol in enum " + in.getText());
  } else {
    throw error("fixed");
  }
}
 
开发者ID:openaire,项目名称:iis,代码行数:17,代码来源:HackedJsonDecoder.java

示例7: readBoolean

import org.apache.avro.io.parsing.Symbol; //导入依赖的package包/类
@Override
public boolean readBoolean() throws IOException {
    advance(Symbol.BOOLEAN);
    JsonToken t = in.getCurrentToken();
      if (t == JsonToken.VALUE_TRUE || t == JsonToken.VALUE_FALSE) {
        in.nextToken();
        return t == JsonToken.VALUE_TRUE;
    } else {
        String s = in.getText();
        if(s.equals("false") || s.equals("FALSE") || s.equals("0")) {
            in.nextToken();
            return false;
        }
        else if(s.equals("true") || s.equals("TRUE") || s.equals("1")) {
            in.nextToken();
            return true;
        }
        throw error("boolean");
    }
}
 
开发者ID:whale2,项目名称:iow-hadoop-streaming,代码行数:21,代码来源:IOWJsonDecoder.java

示例8: readInt

import org.apache.avro.io.parsing.Symbol; //导入依赖的package包/类
@Override
public int readInt() throws IOException {
    advance(Symbol.INT);
    if (in.getCurrentToken().isNumeric()) {
        int result = in.getIntValue();
        in.nextToken();
        return result;
    } else {
        try {
            String s = in.getText();
            in.nextToken();
            return Integer.parseInt(s);
        }
        catch(Exception e) {
            throw error("int (" + e.getMessage() + ")");
        }
    }
}
 
开发者ID:whale2,项目名称:iow-hadoop-streaming,代码行数:19,代码来源:IOWJsonDecoder.java

示例9: readLong

import org.apache.avro.io.parsing.Symbol; //导入依赖的package包/类
@Override
public long readLong() throws IOException {
    advance(Symbol.LONG);
    if (in.getCurrentToken().isNumeric()) {
        long result = in.getLongValue();
        in.nextToken();
        return result;
    } else {
        try {
            String s = in.getText();
            in.nextToken();
            return Long.parseLong(s);
        }
        catch(Exception e) {
            throw error("long (" + e.getMessage() + ")");
        }
    }
}
 
开发者ID:whale2,项目名称:iow-hadoop-streaming,代码行数:19,代码来源:IOWJsonDecoder.java

示例10: readString

import org.apache.avro.io.parsing.Symbol; //导入依赖的package包/类
@Override
public String readString() throws IOException {
    advance(Symbol.STRING);
    if (parser.topSymbol() == Symbol.MAP_KEY_MARKER) {
        parser.advance(Symbol.MAP_KEY_MARKER);
            if (in.getCurrentToken() != JsonToken.FIELD_NAME) {
                throw error("map-key");
            }
        } else {
            if (in.getCurrentToken() != JsonToken.VALUE_STRING) {
            throw error("string");
        }
    }
    String result = in.getText();
    in.nextToken();
    return result;
}
 
开发者ID:whale2,项目名称:iow-hadoop-streaming,代码行数:18,代码来源:IOWJsonDecoder.java

示例11: readEnum

import org.apache.avro.io.parsing.Symbol; //导入依赖的package包/类
@Override
public int readEnum() throws IOException {
    advance(Symbol.ENUM);
    Symbol.EnumLabelsAction top = (Symbol.EnumLabelsAction) parser.popSymbol();
    if (in.getCurrentToken() == JsonToken.VALUE_STRING) {
        in.getText();
        int n = top.findLabel(in.getText());
        if (n >= 0) {
            in.nextToken();
            return n;
        }
        throw new AvroTypeException("Unknown symbol in enum " + in.getText());
    } else {
        throw error("fixed");
    }
}
 
开发者ID:whale2,项目名称:iow-hadoop-streaming,代码行数:17,代码来源:IOWJsonDecoder.java

示例12: hasErrorSymbol

import org.apache.avro.io.parsing.Symbol; //导入依赖的package包/类
/**
 * Determine if the symbol tree has an error symbol in it. This would indicate
 * that the two schemas are not compatible.
 * 
 * @param rootSymbol
 *          The root symbol to traverse from to look for an error symbol.
 * @return true if an error symbol exists in the tree.
 */
private static boolean hasErrorSymbol(Symbol rootSymbol) {
  if (rootSymbol.production == null) {
    return false;
  }
  for (Symbol s : rootSymbol.production) {
    if (s == rootSymbol) {
      continue;
    }
    if (s.getClass().equals(Symbol.ErrorAction.class)) {
      return true;
    } else {
      if (s.production != null) {
        for (Symbol subSymbol : s.production) {
          if (hasErrorSymbol(subSymbol)) {
            return true;
          }
        }
      }
    }
  }
  return false;
}
 
开发者ID:cloudera,项目名称:cdk,代码行数:31,代码来源:AvroEntitySchema.java

示例13: hasErrors

import org.apache.avro.io.parsing.Symbol; //导入依赖的package包/类
/**
 * Returns true if the Parser contains any Error symbol, indicating that it may fail
 * for some inputs.
 */
private static boolean hasErrors(Symbol symbol) {
  switch(symbol.kind) {
    case ALTERNATIVE:
      return hasErrors(((Symbol.Alternative) symbol).symbols);
    case EXPLICIT_ACTION:
      return false;
    case IMPLICIT_ACTION:
      return symbol instanceof Symbol.ErrorAction;
    case REPEATER:
      Symbol.Repeater r = (Symbol.Repeater) symbol;
      return hasErrors(r.end) || hasErrors(r.production);
    case ROOT:
      return hasErrors(Arrays.copyOfRange(symbol.production, 1, symbol.production.length));
    case SEQUENCE:
      return hasErrors(symbol.production);
    case TERMINAL:
      return false;
    default:
      throw new RuntimeException("unknown symbol kind: " + symbol.kind);
  }
}
 
开发者ID:cloudera,项目名称:cdk,代码行数:26,代码来源:SchemaValidationUtil.java

示例14: readNull

import org.apache.avro.io.parsing.Symbol; //导入依赖的package包/类
@Override
public void readNull() throws IOException {
	advance(Symbol.NULL);
	if (in.getCurrentToken() == JsonToken.VALUE_NULL) {
		in.nextToken();
	} else {
		throw error("null");
	}
}
 
开发者ID:Celos,项目名称:avro-json-decoder,代码行数:10,代码来源:ExtendedJsonDecoder.java

示例15: readBoolean

import org.apache.avro.io.parsing.Symbol; //导入依赖的package包/类
@Override
public boolean readBoolean() throws IOException {
	advance(Symbol.BOOLEAN);
	JsonToken t = in.getCurrentToken();
	if (t == JsonToken.VALUE_TRUE || t == JsonToken.VALUE_FALSE) {
		in.nextToken();
		return t == JsonToken.VALUE_TRUE;
	} else {
		throw error("boolean");
	}
}
 
开发者ID:Celos,项目名称:avro-json-decoder,代码行数:12,代码来源:ExtendedJsonDecoder.java


注:本文中的org.apache.avro.io.parsing.Symbol类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。