Java Code Examples for java.util.EnumMap#get()
The following examples show how to use
java.util.EnumMap#get() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RelativeDateTimeFormatter.java From j2objc with Apache License 2.0 | 6 votes |
private String getRelativeUnitPattern( Style style, RelativeUnit unit, int pastFutureIndex, StandardPlural pluralForm) { int pluralIndex = pluralForm.ordinal(); do { EnumMap<RelativeUnit, String[][]> unitMap = patternMap.get(style); if (unitMap != null) { String[][] spfCompiledPatterns = unitMap.get(unit); if (spfCompiledPatterns != null) { if (spfCompiledPatterns[pastFutureIndex][pluralIndex] != null) { return spfCompiledPatterns[pastFutureIndex][pluralIndex]; } } } // Consider other styles from alias fallback. // Data loading guaranteed no endless loops. } while ((style = fallbackCache[style.ordinal()]) != null); return null; }
Example 2
Source File: ValueConversions.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** Return a method that casts its sole argument (an Object) to the given type * and returns it as the given type. */ public static MethodHandle cast(Class<?> type) { if (type.isPrimitive()) throw new IllegalArgumentException("cannot cast primitive type "+type); MethodHandle mh; Wrapper wrap = null; EnumMap<Wrapper, MethodHandle> cache = null; if (Wrapper.isWrapperType(type)) { wrap = Wrapper.forWrapperType(type); cache = WRAPPER_CASTS[0]; mh = cache.get(wrap); if (mh != null) return mh; } mh = MethodHandles.insertArguments(CAST_REFERENCE, 0, type); if (cache != null) cache.put(wrap, mh); return mh; }
Example 3
Source File: RelativeDateTimeFormatter.java From fitnotifications with Apache License 2.0 | 6 votes |
private void handlePlainDirection(UResource.Key key, UResource.Value value) { AbsoluteUnit absUnit = unit.absUnit; if (absUnit == null) { return; // Not interesting. } EnumMap<AbsoluteUnit, EnumMap<Direction, String>> unitMap = qualitativeUnitMap.get(style); if (unitMap == null) { unitMap = new EnumMap<AbsoluteUnit, EnumMap<Direction, String>>(AbsoluteUnit.class); qualitativeUnitMap.put(style, unitMap); } EnumMap<Direction,String> dirMap = unitMap.get(absUnit); if (dirMap == null) { dirMap = new EnumMap<Direction,String>(Direction.class); unitMap.put(absUnit, dirMap); } if (dirMap.get(Direction.PLAIN) == null) { dirMap.put(Direction.PLAIN, value.toString()); } }
Example 4
Source File: FSImageTestUtil.java From big-c with Apache License 2.0 | 6 votes |
/** * @see #countEditLogOpTypes(File) */ public static EnumMap<FSEditLogOpCodes, Holder<Integer>> countEditLogOpTypes( EditLogInputStream elis) throws IOException { EnumMap<FSEditLogOpCodes, Holder<Integer>> opCounts = new EnumMap<FSEditLogOpCodes, Holder<Integer>>(FSEditLogOpCodes.class); FSEditLogOp op; while ((op = elis.readOp()) != null) { Holder<Integer> i = opCounts.get(op.opCode); if (i == null) { i = new Holder<Integer>(0); opCounts.put(op.opCode, i); } i.held++; } return opCounts; }
Example 5
Source File: AbstractAST.java From symja_android_library with GNU General Public License v3.0 | 5 votes |
/** * Returns the value to which the specified property is mapped, or <code>null</code> if this map contains no mapping * for the property. * * @param key * @return * @see #putProperty(PROPERTY, Object) */ public Object getProperty(PROPERTY key) { if (IAST_CACHE != null) { EnumMap<PROPERTY, Object> map = IAST_CACHE.getIfPresent(this); if (map == null) { return null; } return map.get(key); } return null; }
Example 6
Source File: FileSourceGPX.java From gama with GNU General Public License v3.0 | 5 votes |
/** * <pre> * name : LINK * attributes : LINKAttribute * structure : TEXT? TYPE? * </pre> * * @throws IOException * @throws XMLStreamException */ private String __link() throws IOException, XMLStreamException { String link; XMLEvent e; EnumMap<LINKAttribute, String> attributes; e = getNextEvent(); checkValid(e, XMLEvent.START_ELEMENT, "link"); attributes = getAttributes(LINKAttribute.class, e.asStartElement()); if (!attributes.containsKey(LINKAttribute.HREF)) { newParseError(e, false, "attribute 'href' is required"); link = "unknown"; } else link = attributes.get(LINKAttribute.HREF); e = getNextEvent(); if (isEvent(e, XMLEvent.START_ELEMENT, "text")) { pushback(e); __text(); e = getNextEvent(); } if (isEvent(e, XMLEvent.START_ELEMENT, "type")) { pushback(e); __type(); e = getNextEvent(); } checkValid(e, XMLEvent.END_ELEMENT, "link"); return link; }
Example 7
Source File: ValueConversions.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public static MethodHandle identity(Wrapper wrap) { EnumMap<Wrapper, MethodHandle> cache = CONSTANT_FUNCTIONS[1]; MethodHandle mh = cache.get(wrap); if (mh != null) { return mh; } // slow path MethodType type = MethodType.methodType(wrap.primitiveType()); if (wrap != Wrapper.VOID) type = type.appendParameterTypes(wrap.primitiveType()); try { mh = IMPL_LOOKUP.findStatic(THIS_CLASS, "identity", type); } catch (ReflectiveOperationException ex) { mh = null; } if (mh == null && wrap == Wrapper.VOID) { mh = EMPTY; // #(){} : #()void } if (mh != null) { cache.put(wrap, mh); return mh; } if (mh != null) { cache.put(wrap, mh); return mh; } throw new IllegalArgumentException("cannot find identity for " + wrap); }
Example 8
Source File: SelectiveAccessHandler.java From dkpro-jwpl with Apache License 2.0 | 5 votes |
private static void handleContent( Content c, EnumMap<CIT, Boolean> hp, StringBuilder sb ){ if( hp != null ){ if( hp.get( CIT.TEXT )) sb.append( c.getText()+" " ); else{ if( hp.get( CIT.BOLD ) ) handleSpans( c.getFormatSpans( FormatType.BOLD), c.getText(), sb ); if( hp.get( CIT.ITALIC )) handleSpans( c.getFormatSpans( FormatType.ITALIC), c.getText(), sb ); } if( hp.get( CIT.LINK )) handleLinks( c.getLinks(), !hp.get( CIT.TEXT ), sb ); } }
Example 9
Source File: ValueConversions.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private static MethodHandle unbox(Wrapper wrap, boolean cast) { EnumMap<Wrapper, MethodHandle> cache = UNBOX_CONVERSIONS[(cast?1:0)]; MethodHandle mh = cache.get(wrap); if (mh != null) { return mh; } // slow path switch (wrap) { case OBJECT: mh = IDENTITY; break; case VOID: mh = IGNORE; break; } if (mh != null) { cache.put(wrap, mh); return mh; } // look up the method String name = "unbox" + wrap.wrapperSimpleName(); MethodType type = unboxType(wrap); try { mh = IMPL_LOOKUP.findStatic(THIS_CLASS, name, type); } catch (ReflectiveOperationException ex) { mh = null; } if (mh != null) { mh = MethodHandles.insertArguments(mh, 1, cast); cache.put(wrap, mh); return mh; } throw new IllegalArgumentException("cannot find unbox adapter for " + wrap + (cast ? " (cast)" : "")); }
Example 10
Source File: Synch.java From pegasus with Apache License 2.0 | 5 votes |
/** * Returns value and throws an exception if required * * @param map * @param type * @param required * @return */ private String getEntityValue( EnumMap<BATCH_ENTITY_TYPE, String> map, BATCH_ENTITY_TYPE type, boolean required) { String value = map.get(type); if (value == null && required) { throw new RuntimeException(type + " needs to be specified "); } return value; }
Example 11
Source File: FileSourceGPX.java From gama with GNU General Public License v3.0 | 5 votes |
/** * <pre> * name : EMAIL * attributes : EMAILAttribute * structure : * </pre> * * @throws IOException * @throws XMLStreamException */ private String __email() throws IOException, XMLStreamException { XMLEvent e; EnumMap<EMAILAttribute, String> attributes; String email = ""; e = getNextEvent(); checkValid(e, XMLEvent.START_ELEMENT, "email"); attributes = getAttributes(EMAILAttribute.class, e.asStartElement()); if (!attributes.containsKey(EMAILAttribute.ID)) { newParseError(e, false, "attribute 'version' is required"); } else email += attributes.get(EMAILAttribute.ID); email += "@"; if (!attributes.containsKey(EMAILAttribute.DOMAIN)) { newParseError(e, false, "attribute 'version' is required"); } else email += attributes.get(EMAILAttribute.DOMAIN); e = getNextEvent(); checkValid(e, XMLEvent.END_ELEMENT, "email"); return email; }
Example 12
Source File: MeasureFormat.java From j2objc with Apache License 2.0 | 5 votes |
void setDnamIfAbsent(UResource.Value value) { EnumMap<FormatWidth, String> styleToDnam = cacheData.unitToStyleToDnam.get(unit); if (styleToDnam == null) { styleToDnam = new EnumMap<FormatWidth, String>(FormatWidth.class); cacheData.unitToStyleToDnam.put(unit, styleToDnam); } if (styleToDnam.get(width) == null) { styleToDnam.put(width, value.getString()); } }
Example 13
Source File: FeatureScopeTracker.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public void addExpressionScope(ResolvedTypes current, EObject context, IFeatureScopeSession session, Anchor anchor) { EnumMap<Anchor, ExpressionScope> recordedScopes = featureScopeSessions.get(context); if (recordedScopes == null) { recordedScopes = Maps.newEnumMap(Anchor.class); featureScopeSessions.put(context, recordedScopes); } ExpressionScope scope = recordedScopes.get(anchor); if (scope == null) { scope = new ExpressionScope(current.getResolver().getFeatureScopes(), context, anchor, current.getReferenceOwner()); recordedScopes.put(anchor, scope); } scope.addData(session, current.withFlattenedReassignedTypes()); }
Example 14
Source File: FSEditLogLoader.java From big-c with Apache License 2.0 | 5 votes |
private void incrOpCount(FSEditLogOpCodes opCode, EnumMap<FSEditLogOpCodes, Holder<Integer>> opCounts, Step step, Counter counter) { Holder<Integer> holder = opCounts.get(opCode); if (holder == null) { holder = new Holder<Integer>(1); opCounts.put(opCode, holder); } else { holder.held++; } counter.increment(); }
Example 15
Source File: Properties.java From es6draft with MIT License | 4 votes |
private static void createExternalAccessor(ExecutionContext cx, Accessor accessor, MethodHandle handle, LinkedHashMap<String, PropertyDescriptor> stringProps, EnumMap<BuiltinSymbol, PropertyDescriptor> symbolProps) { Accessor.Type type = accessor.type(); String name = accessor.name(); BuiltinSymbol symbol = accessor.symbol(); Attributes attributes = accessor.attributes(); String functionName = accessorName(type, name, symbol); int arity = accessorArity(type); NativeFunction fun = new NativeFunction(cx.getRealm(), functionName, arity, handle); PropertyDescriptor existing; if (symbol == BuiltinSymbol.NONE) { existing = stringProps.get(name); } else { existing = symbolProps.get(symbol); } PropertyDescriptor desc; if (existing != null) { if (attributes.enumerable() != existing.isEnumerable() || attributes.configurable() != existing.isConfigurable()) { throw new IllegalArgumentException(); } if (type == Accessor.Type.Getter ? existing.getGetter() != null : existing.getSetter() != null) { throw new IllegalArgumentException(); } desc = existing; } else { desc = propertyDescriptor(null, null, attributes); } if (type == Accessor.Type.Getter) { desc.setGetter(fun); } else { desc.setSetter(fun); } if (symbol == BuiltinSymbol.NONE) { stringProps.put(name, desc); } else { symbolProps.put(symbol, desc); } }
Example 16
Source File: RoundRobinOperatorStateRepartitioner.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
/** * Group by the different named states. */ @SuppressWarnings("unchecked, rawtype") private GroupByStateNameResults groupByStateMode(List<List<OperatorStateHandle>> previousParallelSubtaskStates) { //Reorganize: group by (State Name -> StreamStateHandle + StateMetaInfo) EnumMap<OperatorStateHandle.Mode, Map<String, List<Tuple2<StreamStateHandle, OperatorStateHandle.StateMetaInfo>>>> nameToStateByMode = new EnumMap<>(OperatorStateHandle.Mode.class); for (OperatorStateHandle.Mode mode : OperatorStateHandle.Mode.values()) { nameToStateByMode.put( mode, new HashMap<>()); } for (List<OperatorStateHandle> previousParallelSubtaskState : previousParallelSubtaskStates) { for (OperatorStateHandle operatorStateHandle : previousParallelSubtaskState) { if (operatorStateHandle == null) { continue; } final Set<Map.Entry<String, OperatorStateHandle.StateMetaInfo>> partitionOffsetEntries = operatorStateHandle.getStateNameToPartitionOffsets().entrySet(); for (Map.Entry<String, OperatorStateHandle.StateMetaInfo> e : partitionOffsetEntries) { OperatorStateHandle.StateMetaInfo metaInfo = e.getValue(); Map<String, List<Tuple2<StreamStateHandle, OperatorStateHandle.StateMetaInfo>>> nameToState = nameToStateByMode.get(metaInfo.getDistributionMode()); List<Tuple2<StreamStateHandle, OperatorStateHandle.StateMetaInfo>> stateLocations = nameToState.computeIfAbsent( e.getKey(), k -> new ArrayList<>(previousParallelSubtaskStates.size() * partitionOffsetEntries.size())); stateLocations.add(Tuple2.of(operatorStateHandle.getDelegateStateHandle(), e.getValue())); } } } return new GroupByStateNameResults(nameToStateByMode); }
Example 17
Source File: RelativeDateTimeFormatter.java From fitnotifications with Apache License 2.0 | 4 votes |
public void consumeTableRelative(UResource.Key key, UResource.Value value) { UResource.Table unitTypesTable = value.getTable(); for (int i = 0; unitTypesTable.getKeyAndValue(i, key, value); i++) { if (value.getType() == ICUResourceBundle.STRING) { String valueString = value.getString(); EnumMap<AbsoluteUnit, EnumMap<Direction, String>> absMap = qualitativeUnitMap.get(style); if (unit.relUnit == RelativeUnit.SECONDS) { if (key.contentEquals("0")) { // Handle Zero seconds for "now". EnumMap<Direction, String> unitStrings = absMap.get(AbsoluteUnit.NOW); if (unitStrings == null) { unitStrings = new EnumMap<Direction, String>(Direction.class); absMap.put(AbsoluteUnit.NOW, unitStrings); } if (unitStrings.get(Direction.PLAIN) == null) { unitStrings.put(Direction.PLAIN, valueString); } continue; } } Direction keyDirection = keyToDirection(key); if (keyDirection == null) { continue; } AbsoluteUnit absUnit = unit.absUnit; if (absUnit == null) { continue; } if (absMap == null) { absMap = new EnumMap<AbsoluteUnit, EnumMap<Direction, String>>(AbsoluteUnit.class); qualitativeUnitMap.put(style, absMap); } EnumMap<Direction, String> dirMap = absMap.get(absUnit); if (dirMap == null) { dirMap = new EnumMap<Direction, String>(Direction.class); absMap.put(absUnit, dirMap); } if (dirMap.get(keyDirection) == null) { // Do not override values already entered. dirMap.put(keyDirection, value.getString()); } } } }
Example 18
Source File: FileSourceGEXF.java From gama with GNU General Public License v3.0 | 4 votes |
/** * <pre> * name : NODESHAPE * attributes : NODESHAPEAttributes { VALUE!, URI, START, STARTOPEN, END, ENDOPEN } * structure : SPELLS ? * </pre> */ private void __node_shape(final String nodeId) throws IOException, XMLStreamException { XMLEvent e; EnumMap<NODESHAPEAttribute, String> attributes; NodeShapeType type = null; String uri; e = getNextEvent(); checkValid(e, XMLEvent.START_ELEMENT, "shape"); attributes = getAttributes(NODESHAPEAttribute.class, e.asStartElement()); checkRequiredAttributes(e, attributes, NODESHAPEAttribute.VALUE); try { type = NodeShapeType.valueOf(toConstantName(attributes.get(NODESHAPEAttribute.VALUE))); } catch (final IllegalArgumentException ex) { newParseError(e, true, "'value' should be one of 'disc', 'diamond', 'triangle', 'square' or 'image'"); } switch (type) { case IMAGE: if (!attributes.containsKey(NODESHAPEAttribute.URI)) { newParseError(e, true, "'image' shape type needs 'uri' attribute"); } uri = attributes.get(NODESHAPEAttribute.URI); sendNodeAttributeAdded(sourceId, nodeId, "ui.style", String.format("fill-mode: image-scaled; fill-image: url('%s');", uri)); break; default: sendNodeAttributeAdded(sourceId, nodeId, "ui.style", String.format("shape: %s;", type.name().toLowerCase())); } e = getNextEvent(); if (isEvent(e, XMLEvent.START_ELEMENT, "spells")) { pushback(e); __spells(); e = getNextEvent(); } checkValid(e, XMLEvent.END_ELEMENT, "shape"); }
Example 19
Source File: RoundRobinOperatorStateRepartitioner.java From flink with Apache License 2.0 | 4 votes |
/** * Group by the different named states. */ @SuppressWarnings("unchecked, rawtype") private GroupByStateNameResults groupByStateMode(List<List<OperatorStateHandle>> previousParallelSubtaskStates) { //Reorganize: group by (State Name -> StreamStateHandle + StateMetaInfo) EnumMap<OperatorStateHandle.Mode, Map<String, List<Tuple2<StreamStateHandle, OperatorStateHandle.StateMetaInfo>>>> nameToStateByMode = new EnumMap<>(OperatorStateHandle.Mode.class); for (OperatorStateHandle.Mode mode : OperatorStateHandle.Mode.values()) { nameToStateByMode.put( mode, new HashMap<>()); } for (List<OperatorStateHandle> previousParallelSubtaskState : previousParallelSubtaskStates) { for (OperatorStateHandle operatorStateHandle : previousParallelSubtaskState) { if (operatorStateHandle == null) { continue; } final Set<Map.Entry<String, OperatorStateHandle.StateMetaInfo>> partitionOffsetEntries = operatorStateHandle.getStateNameToPartitionOffsets().entrySet(); for (Map.Entry<String, OperatorStateHandle.StateMetaInfo> e : partitionOffsetEntries) { OperatorStateHandle.StateMetaInfo metaInfo = e.getValue(); Map<String, List<Tuple2<StreamStateHandle, OperatorStateHandle.StateMetaInfo>>> nameToState = nameToStateByMode.get(metaInfo.getDistributionMode()); List<Tuple2<StreamStateHandle, OperatorStateHandle.StateMetaInfo>> stateLocations = nameToState.computeIfAbsent( e.getKey(), k -> new ArrayList<>(previousParallelSubtaskStates.size() * partitionOffsetEntries.size())); stateLocations.add(Tuple2.of(operatorStateHandle.getDelegateStateHandle(), e.getValue())); } } } return new GroupByStateNameResults(nameToStateByMode); }
Example 20
Source File: HoroscopeExporter.java From Astrosoft with GNU General Public License v2.0 | 2 votes |
public void export(Vimshottari v) { try { xmlWriter.add(xmlef.createStartElement(XmlConsts.VIM_DASA_TAG, null,null)); EnumMap<Planet, Dasa> dasa = v.getDasa(); StringBuilder attrVal = null; for(Planet p : Planet.dasaLords(v.getStartLord())){ Dasa d = dasa.get(p); xmlWriter.add(xmlef.createStartElement(XmlConsts.MAJOR_DASA_TAG, null,null)); xmlWriter.add(xmlef.createAttribute(XmlConsts.Dasa, p.name() + " " + XmlConsts.Dasa)); attrVal = new StringBuilder(" ( "); //attrVal.append(" " + XmlConsts.Dasa); attrVal.append(d.getStartDate()); attrVal.append(" ~ "); attrVal.append(d.getEndDate()); attrVal.append(" )"); xmlWriter.add(xmlef.createAttribute(XmlConsts.Period, attrVal.toString())); for(Dasa sd : d.subDasas()) { attrVal = new StringBuilder(sd.fullDasa()); attrVal.append(" ( "); attrVal.append(sd.getStartDate()); attrVal.append(" ~ "); attrVal.append(sd.getEndDate()); attrVal.append(" )"); Attribute subDasa = xmlef.createAttribute(XmlConsts.Dasa, attrVal.toString() ); exportTableData(v.getVimDasaTableData(sd),Vimshottari.getVimDasaTableColumnMetaData(), XmlConsts.SUB_DASA_TAG, subDasa, XmlConsts.ANTHARA_DASA_TAG); } xmlWriter.add(xmlef.createEndElement(XmlConsts.MAJOR_DASA_TAG, null)); } xmlWriter.add(xmlef.createEndElement(XmlConsts.VIM_DASA_TAG, null)); }catch(Exception e){ log.log(Level.SEVERE, "Exception in writing vimshottari dasa", e); } }