public static TypeInfo getTypeInfoFromTypeString(String typeString) { TypeInfoParser parser = new TypeInfoParser(typeString); return parser.parseTypeInfos().get(0); }
Token t = expect("type"); PrimitiveObjectInspectorUtils.getTypeEntryFromTypeName(t.text); if (typeEntry != null && typeEntry.primitiveCategory != PrimitiveCategory.UNKNOWN ) { String[] params = parseParams(); switch (typeEntry.primitiveCategory) { case CHAR: expect("<"); TypeInfo listElementType = parseType(); expect(">"); return TypeInfoFactory.getListTypeInfo(listElementType); expect("<"); TypeInfo mapKeyType = parseType(); expect(","); TypeInfo mapValueType = parseType(); expect(">"); return TypeInfoFactory.getMapTypeInfo(mapKeyType, mapValueType); do { if (first) { expect("<"); first = false; } else { Token separator = expect(">", ","); if (separator.text.equals(">")) { Token name = expect("name",">");
|| !isTypeChar(typeInfoString.charAt(end - 1)) || !isTypeChar(typeInfoString.charAt(end))) { Token t = new Token(); t.position = begin; t.text = typeInfoString.substring(begin, end); t.isType = isTypeChar(typeInfoString.charAt(begin)); tokens.add(t); begin = end;
Token t = expect("type"); PrimitiveObjectInspectorUtils.getTypeEntryFromTypeName(t.text); if (typeEntry != null && typeEntry.primitiveCategory != PrimitiveCategory.UNKNOWN ) { String[] params = parseParams(); switch (typeEntry.primitiveCategory) { case CHAR: expect("<"); TypeInfo listElementType = parseType(); expect(">"); return TypeInfoFactory.getListTypeInfo(listElementType); expect("<"); TypeInfo mapKeyType = parseType(); expect(","); TypeInfo mapValueType = parseType(); expect(">"); return TypeInfoFactory.getMapTypeInfo(mapKeyType, mapValueType); do { if (first) { expect("<"); first = false; } else { Token separator = expect(">", ","); if (separator.text.equals(">")) { Token name = expect("name",">");
Token t = expect("type"); PrimitiveObjectInspectorUtils.getTypeEntryFromTypeName(t.text); if (typeEntry != null && typeEntry.primitiveCategory != PrimitiveCategory.UNKNOWN ) { String[] params = parseParams(); switch (typeEntry.primitiveCategory) { case CHAR: expect("<"); TypeInfo listElementType = parseType(); expect(">"); return TypeInfoFactory.getListTypeInfo(listElementType); expect("<"); TypeInfo mapKeyType = parseType(); expect(","); TypeInfo mapValueType = parseType(); expect(">"); return TypeInfoFactory.getMapTypeInfo(mapKeyType, mapValueType); do { if (first) { expect("<"); first = false; } else { Token separator = expect(">", ","); if (separator.text.equals(">")) { Token name = expect("name",">");
Token t = expect("type"); PrimitiveObjectInspectorUtils.getTypeEntryFromTypeName(t.text); if (typeEntry != null && typeEntry.primitiveCategory != PrimitiveCategory.UNKNOWN ) { String[] params = parseParams(); switch (typeEntry.primitiveCategory) { case CHAR: expect("<"); TypeInfo listElementType = parseType(); expect(">"); return TypeInfoFactory.getListTypeInfo(listElementType); expect("<"); TypeInfo mapKeyType = parseType(); expect(","); TypeInfo mapValueType = parseType(); expect(">"); return TypeInfoFactory.getMapTypeInfo(mapKeyType, mapValueType); do { if (first) { expect("<"); first = false; } else { Token separator = expect(">", ","); if (separator.text.equals(">")) { Token name = expect("name",">");
Token t = expect("type"); PrimitiveObjectInspectorUtils.getTypeEntryFromTypeName(t.text); if (typeEntry != null && typeEntry.primitiveCategory != PrimitiveCategory.UNKNOWN ) { String[] params = parseParams(); switch (typeEntry.primitiveCategory) { case CHAR: expect("<"); TypeInfo listElementType = parseType(); expect(">"); return TypeInfoFactory.getListTypeInfo(listElementType); expect("<"); TypeInfo mapKeyType = parseType(); expect(","); TypeInfo mapValueType = parseType(); expect(">"); return TypeInfoFactory.getMapTypeInfo(mapKeyType, mapValueType); do { if (first) { expect("<"); first = false; } else { Token separator = expect(">", ","); if (separator.text.equals(">")) { Token name = expect("name",">");
|| !isTypeChar(typeInfoString.charAt(end - 1)) || !isTypeChar(typeInfoString.charAt(end))) { Token t = new Token(); t.position = begin; t.text = typeInfoString.substring(begin, end); t.isType = isTypeChar(typeInfoString.charAt(begin)); tokens.add(t); begin = end;
/** * Tokenize the typeInfoString. The rule is simple: all consecutive * alphadigits and '_', '.' are in one token, and all other characters are * one character per token. * * tokenize("map<int,string>") should return * ["map","<","int",",","string",">"] */ private static ArrayList<Token> tokenize(String typeInfoString) { ArrayList<Token> tokens = new ArrayList<Token>(0); int begin = 0; int end = 1; while (end <= typeInfoString.length()) { // last character ends a token? if (end == typeInfoString.length() || !isTypeChar(typeInfoString.charAt(end - 1)) || !isTypeChar(typeInfoString.charAt(end))) { Token t = new Token(); t.position = begin; t.text = typeInfoString.substring(begin, end); t.isType = isTypeChar(typeInfoString.charAt(begin)); tokens.add(t); begin = end; } end++; } return tokens; }
/** * Tokenize the typeInfoString. The rule is simple: all consecutive * alphadigits and '_', '.' are in one token, and all other characters are * one character per token. * * tokenize("map<int,string>") should return * ["map","<","int",",","string",">"] */ private static ArrayList<Token> tokenize(String typeInfoString) { ArrayList<Token> tokens = new ArrayList<Token>(0); int begin = 0; int end = 1; while (end <= typeInfoString.length()) { // last character ends a token? if (end == typeInfoString.length() || !isTypeChar(typeInfoString.charAt(end - 1)) || !isTypeChar(typeInfoString.charAt(end))) { Token t = new Token(); t.position = begin; t.text = typeInfoString.substring(begin, end); t.isType = isTypeChar(typeInfoString.charAt(begin)); tokens.add(t); begin = end; } end++; } return tokens; }
/** * Tokenize the typeInfoString. The rule is simple: all consecutive * alphadigits and '_', '.' are in one token, and all other characters are * one character per token. * * tokenize("map<int,string>") should return * ["map","<","int",",","string",">"] */ private static ArrayList<Token> tokenize(String typeInfoString) { ArrayList<Token> tokens = new ArrayList<Token>(0); int begin = 0; int end = 1; while (end <= typeInfoString.length()) { // last character ends a token? if (end == typeInfoString.length() || !isTypeChar(typeInfoString.charAt(end - 1)) || !isTypeChar(typeInfoString.charAt(end))) { Token t = new Token(); t.position = begin; t.text = typeInfoString.substring(begin, end); t.isType = isTypeChar(typeInfoString.charAt(begin)); tokens.add(t); begin = end; } end++; } return tokens; }
public ArrayList<TypeInfo> parseTypeInfos() { typeInfos = new ArrayList<TypeInfo>(); iToken = 0; while (iToken < typeInfoTokens.size()) { typeInfos.add(parseType()); if (iToken < typeInfoTokens.size()) { Token separator = typeInfoTokens.get(iToken); if (",".equals(separator.text) || ";".equals(separator.text) || ":".equals(separator.text)) { iToken++; } else { throw new IllegalArgumentException( "Error: ',', ':', or ';' expected at position " + separator.position + " from '" + typeInfoString + "' " + typeInfoTokens); } } } return typeInfos; }
public ArrayList<TypeInfo> parseTypeInfos() { typeInfos = new ArrayList<TypeInfo>(); iToken = 0; while (iToken < typeInfoTokens.size()) { typeInfos.add(parseType()); if (iToken < typeInfoTokens.size()) { Token separator = typeInfoTokens.get(iToken); if (",".equals(separator.text) || ";".equals(separator.text) || ":".equals(separator.text)) { iToken++; } else { throw new IllegalArgumentException( "Error: ',', ':', or ';' expected at position " + separator.position + " from '" + typeInfoString + "' " + typeInfoTokens); } } } return typeInfos; }
public ArrayList<TypeInfo> parseTypeInfos() { typeInfos = new ArrayList<TypeInfo>(); iToken = 0; while (iToken < typeInfoTokens.size()) { typeInfos.add(parseType()); if (iToken < typeInfoTokens.size()) { Token separator = typeInfoTokens.get(iToken); if (",".equals(separator.text) || ";".equals(separator.text) || ":".equals(separator.text)) { iToken++; } else { throw new IllegalArgumentException( "Error: ',', ':', or ';' expected at position " + separator.position + " from '" + typeInfoString + "' " + typeInfoTokens); } } } return typeInfos; }
public ArrayList<TypeInfo> parseTypeInfos() { typeInfos = new ArrayList<TypeInfo>(); iToken = 0; while (iToken < typeInfoTokens.size()) { typeInfos.add(parseType()); if (iToken < typeInfoTokens.size()) { Token separator = typeInfoTokens.get(iToken); if (",".equals(separator.text) || ";".equals(separator.text) || ":".equals(separator.text)) { iToken++; } else { throw new IllegalArgumentException( "Error: ',', ':', or ';' expected at position " + separator.position + " from '" + typeInfoString + "' " + typeInfoTokens); } } } return typeInfos; }
private String[] parseParams() { List<String> params = new LinkedList<String>(); Token t = peek(); if (t != null && t.text.equals("(")) { expect("("); // checking for null in the for-loop condition prevents null-ptr exception // and allows us to fail more gracefully with a parsing error. for(t = peek(); (t == null) || !t.text.equals(")"); t = expect(",",")")) { params.add(expect("name").text); } if (params.size() == 0) { throw new IllegalArgumentException( "type parameters expected for type string " + typeInfoString); } } return params.toArray(new String[params.size()]); }
private String[] parseParams() { List<String> params = new LinkedList<String>(); Token t = peek(); if (t != null && t.text.equals("(")) { expect("("); // checking for null in the for-loop condition prevents null-ptr exception // and allows us to fail more gracefully with a parsing error. for(t = peek(); (t == null) || !t.text.equals(")"); t = expect(",",")")) { params.add(expect("name").text); } if (params.size() == 0) { throw new IllegalArgumentException( "type parameters expected for type string " + typeInfoString); } } return params.toArray(new String[params.size()]); }
private String[] parseParams() { List<String> params = new LinkedList<String>(); Token t = peek(); if (t != null && t.text.equals("(")) { expect("("); // checking for null in the for-loop condition prevents null-ptr exception // and allows us to fail more gracefully with a parsing error. for(t = peek(); (t == null) || !t.text.equals(")"); t = expect(",",")")) { params.add(expect("name").text); } if (params.size() == 0) { throw new IllegalArgumentException( "type parameters expected for type string " + typeInfoString); } } return params.toArray(new String[params.size()]); }
private String[] parseParams() { List<String> params = new LinkedList<String>(); Token t = peek(); if (t != null && t.text.equals("(")) { expect("("); // checking for null in the for-loop condition prevents null-ptr exception // and allows us to fail more gracefully with a parsing error. for(t = peek(); (t == null) || !t.text.equals(")"); t = expect(",",")")) { params.add(expect("name").text); } if (params.size() == 0) { throw new IllegalArgumentException( "type parameters expected for type string " + typeInfoString); } } return params.toArray(new String[params.size()]); }
private Token expect(String item) { return expect(item, null); }