public static void annotateChunk(CoreMap chunk, Map<String,String> attributes) { for (Map.Entry<String, String> entry : attributes.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); Class coreKeyClass = AnnotationLookup.toCoreKey(key); if (key != null) { if (value != null) { try { Class valueClass = AnnotationLookup.getValueType(coreKeyClass); if (valueClass == String.class) { chunk.set(coreKeyClass, value); } else { Method valueOfMethod = valueClass.getMethod("valueOf", String.class); if (valueOfMethod != null) { chunk.set(coreKeyClass, valueOfMethod.invoke(valueClass, value)); } } } catch (Exception ex) { throw new RuntimeException("Unable to annotate attribute " + key, ex); } } else { chunk.set(coreKeyClass, null); } } else { throw new UnsupportedOperationException("Unknown null attribute."); } } }
public static void annotateChunk(CoreMap chunk, Map<String,String> attributes) { for (String attr:attributes.keySet()) { String value = attributes.get(attr); AnnotationLookup.KeyLookup lookup = AnnotationLookup.getCoreKey(attr); if (attr != null) { if (value != null) { try { Class valueClass = AnnotationLookup.getValueType(lookup.coreKey); if (valueClass == String.class) { chunk.set((Class<? extends CoreAnnotation>) lookup.coreKey, value); } else { Method valueOfMethod = valueClass.getMethod("valueOf", String.class); if (valueOfMethod != null) { chunk.set((Class<? extends CoreAnnotation>) lookup.coreKey, valueOfMethod.invoke(valueClass, value)); } } } catch (Exception ex) { throw new RuntimeException("Unable to annotate attribute " + attr, ex); } } else { chunk.set((Class<? extends CoreAnnotation>) lookup.coreKey, null); } } else { throw new UnsupportedOperationException("Unknown attributes: " + attr); } } }
String value = values[i]; try { Class<?> valueClass = AnnotationLookup.getValueType(coreKeyClass); if (valueClass.equals(String.class)) { this.set(coreKeyClass, values[i]); + "Bad type for " + coreKeyClass.getSimpleName() + ". Value was: " + value + "; expected "+AnnotationLookup.getValueType(coreKeyClass), e);
@SuppressWarnings("rawtypes") public static Class[] parseStringKeys(String[] keys) { Class[] classes = new Class[keys.length]; for (int i = 0; i < keys.length; i++) { String key = keys[i]; classes[i] = AnnotationLookup.toCoreKey(key); // now work with the key we got above if (classes[i] == null) { throw new UnsupportedOperationException("Unknown key " + key); } } return classes; }
private static Class lookupAnnotationKey(SequencePattern.Env env, String name) { if (env != null) { Object obj = env.get(name); if (obj != null && obj instanceof Class) { return (Class) obj; } } AnnotationLookup.KeyLookup lookup = AnnotationLookup.getCoreKey(name); if (lookup != null) { return lookup.coreKey; } else { return null; } }
public static void annotateChunk(CoreMap chunk, Map<String,String> attributes) { for (String attr:attributes.keySet()) { String value = attributes.get(attr); AnnotationLookup.KeyLookup lookup = AnnotationLookup.getCoreKey(attr); if (attr != null) { if (value != null) { try { Class valueClass = AnnotationLookup.getValueType(lookup.coreKey); if (valueClass == String.class) { chunk.set(lookup.coreKey, value); } else { Method valueOfMethod = valueClass.getMethod("valueOf", String.class); if (valueOfMethod != null) { chunk.set(lookup.coreKey, valueOfMethod.invoke(valueClass, value)); } } } catch (Exception ex) { throw new RuntimeException("Unable to annotate attribute " + attr, ex); } } else { chunk.set(lookup.coreKey, null); } } else { throw new UnsupportedOperationException("Unknown attributes: " + attr); } } }
String value = values[i]; try { Class<?> valueClass = AnnotationLookup.getValueType(coreKeyClass); if (valueClass.equals(String.class)) { this.set(coreKeyClass, values[i]); + "Bad type for " + coreKeyClass.getSimpleName() + ". Value was: " + value + "; expected "+AnnotationLookup.getValueType(coreKeyClass), e);
private static List<Class<? extends CoreAnnotation<?>>> getKeysToPrint(String columns) { if (columns == null) { columns = DEFAULT_KEYS; } String[] keyArray = columns.split(" *, *"); List<Class<? extends CoreAnnotation<?>>> keyList = new ArrayList<>(); for (String key : keyArray) { keyList.add(AnnotationLookup.toCoreKey(key)); } return keyList; }
public static Class lookupAnnotationKey(Env env, String name) { if (env != null) { Object obj = env.get(name); if (obj != null) { if (obj instanceof Class) { return (Class) obj; } else if (obj instanceof Value) { obj = ((Value) obj).get(); if (obj instanceof Class) { return (Class) obj; } } } } AnnotationLookup.KeyLookup lookup = AnnotationLookup.getCoreKey(name); if (lookup != null) { return lookup.coreKey; } else { try { Class clazz = Class.forName(name); return clazz; } catch (ClassNotFoundException ex) {} return null; } }
String key = keys[i]; String value = values[i]; Class coreKeyClass = AnnotationLookup.toCoreKey(key); Class<?> valueClass = AnnotationLookup.getValueType(coreKeyClass); if(valueClass.equals(String.class)) { this.set(coreKeyClass, values[i]); + "Bad type for " + key + ". Value was: " + value + "; expected "+AnnotationLookup.getValueType(coreKeyClass), e);
String key = keys[i]; String value = values[i]; KeyLookup lookup = AnnotationLookup.getCoreKey(key); Class<?> valueClass = AnnotationLookup.getValueType(lookup.coreKey); if(valueClass.equals(String.class)) { this.set((Class<? extends CoreAnnotation>)lookup.coreKey, values[i]); + "Bad type for " + key + ". Value was: " + value + "; expected "+AnnotationLookup.getValueType(lookup.coreKey));
String value = values[i]; try { Class<?> valueClass = AnnotationLookup.getValueType(coreKeyClass); if (valueClass.equals(String.class)) { this.set(coreKeyClass, values[i]); + "Bad type for " + coreKeyClass.getSimpleName() + ". Value was: " + value + "; expected "+AnnotationLookup.getValueType(coreKeyClass), e);
public static Class lookupAnnotationKey(Env env, String name){ if (env != null) { Object obj = env.get(name); if (obj != null) { if (obj instanceof Class) { return (Class) obj; } // else if (obj instanceof Value) { // obj = ((Value) obj).get(); // if (obj instanceof Class) { // return (Class) obj; // } // } } } Class coreKeyClass = AnnotationLookup.toCoreKey(name); if (coreKeyClass != null) { return coreKeyClass; } else { try { Class clazz = Class.forName(name); return clazz; } catch (ClassNotFoundException ex) { return null; } } }
public static void annotateChunk(CoreMap chunk, Map<String,String> attributes) { for (Map.Entry<String, String> entry : attributes.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); Class coreKeyClass = AnnotationLookup.toCoreKey(key); if (key != null) { if (value != null) { try { Class valueClass = AnnotationLookup.getValueType(coreKeyClass); if (valueClass == String.class) { chunk.set(coreKeyClass, value); } else { Method valueOfMethod = valueClass.getMethod("valueOf", String.class); if (valueOfMethod != null) { chunk.set(coreKeyClass, valueOfMethod.invoke(valueClass, value)); } } } catch (Exception ex) { throw new RuntimeException("Unable to annotate attribute " + key, ex); } } else { chunk.set(coreKeyClass, null); } } else { throw new UnsupportedOperationException("Unknown null attribute."); } } }
String key = keys[i]; String value = values[i]; KeyLookup lookup = AnnotationLookup.getCoreKey(key); Class<?> valueClass = AnnotationLookup.getValueType(lookup.coreKey); if(valueClass.equals(String.class)) { this.set(lookup.coreKey, values[i]); + "Bad type for " + key + ". Value was: " + value + "; expected "+AnnotationLookup.getValueType(lookup.coreKey));
public static Class lookupAnnotationKey(Env env, String name) { if (env != null) { Object obj = env.get(name); if (obj != null) { if (obj instanceof Class) { return (Class) obj; } else if (obj instanceof Value) { obj = ((Value) obj).get(); if (obj instanceof Class) { return (Class) obj; } } } } return AnnotationLookup.toCoreKey(name); }
public static void annotateChunk(CoreMap chunk, Map<String,String> attributes) { for (Map.Entry<String, String> entry : attributes.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); Class coreKeyClass = AnnotationLookup.toCoreKey(key); if (key != null) { if (value != null) { try { Class valueClass = AnnotationLookup.getValueType(coreKeyClass); if (valueClass == String.class) { chunk.set(coreKeyClass, value); } else { Method valueOfMethod = valueClass.getMethod("valueOf", String.class); if (valueOfMethod != null) { chunk.set(coreKeyClass, valueOfMethod.invoke(valueClass, value)); } } } catch (Exception ex) { throw new RuntimeException("Unable to annotate attribute " + key, ex); } } else { chunk.set(coreKeyClass, null); } } else { throw new UnsupportedOperationException("Unknown null attribute."); } } }
@SuppressWarnings("rawtypes") public static Class[] parseStringKeys(String[] keys) { Class[] classes = new Class[keys.length]; for (int i = 0; i < keys.length; i++) { String key = keys[i]; classes[i] = AnnotationLookup.toCoreKey(key); // now work with the key we got above if (classes[i] == null) { throw new UnsupportedOperationException("Unknown key " + key); } } return classes; }
String key = keys[i]; String value = values[i]; Class coreKeyClass = AnnotationLookup.toCoreKey(key); Class<?> valueClass = AnnotationLookup.getValueType(coreKeyClass); if(valueClass.equals(String.class)) { this.set(coreKeyClass, values[i]); + "Bad type for " + key + ". Value was: " + value + "; expected "+AnnotationLookup.getValueType(coreKeyClass), e);
@SuppressWarnings("rawtypes") public static Class[] parseStringKeys(String[] keys) { Class[] classes = new Class[keys.length]; for (int i = 0; i < keys.length; i++) { String key = keys[i]; classes[i] = AnnotationLookup.toCoreKey(key); // now work with the key we got above if (classes[i] == null) { throw new UnsupportedOperationException("Unknown key " + key); } } return classes; }