• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Symbol类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: 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 {
		throw error("int");
	}
}
 
开发者ID:Celos,项目名称:avro-json-decoder,代码行数:12,代码来源:ExtendedJsonDecoder.java


示例17: 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 {
		throw error("long");
	}
}
 
开发者ID:Celos,项目名称:avro-json-decoder,代码行数:12,代码来源:ExtendedJsonDecoder.java


示例18: readFloat

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


示例19: readDouble

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


示例20: skipString

import org.apache.avro.io.parsing.Symbol; //导入依赖的package包/类
@Override
public void skipString() 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");
		}
	}
	in.nextToken();
}
 
开发者ID:Celos,项目名称:avro-json-decoder,代码行数:16,代码来源:ExtendedJsonDecoder.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DisallowSnapshotRequestProto类代码示例发布时间:2022-05-22
下一篇:
Java MendixRuntimeException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap