Java Code Examples for java.util.EnumMap

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project kryo-serializers, under directory /src/main/java/de/javakaffee/kryoserializers/.

Source file: EnumMapSerializer.java

  22 
vote

@SuppressWarnings("unchecked") @Override public EnumMap<?,?> read(final ByteBuffer buffer){
  final Class<?> keyType=_kryo.readClass(buffer).getType();
  final EnumMap result=new EnumMap(keyType);
  final int size=IntSerializer.get(buffer,true);
  for (int i=0; i < size; i++) {
    final Object key=EnumSerializer.get(buffer,keyType);
    final Object value=_kryo.readClassAndObject(buffer);
    result.put(key,value);
  }
  return result;
}
 

Example 2

From project sandbox, under directory /xwiki-security-rightservice/src/main/java/org/xwiki/security/internal/.

Source file: PrioritizingRightResolver.java

  21 
vote

/** 
 * Compute the access level of a particular document hierarchy level.
 * @param user The user.
 * @param groups The groups where the user is a member.
 * @param rightsObjects The rights objects at this level in the document hierarchy.
 * @param ref The entity reference that specifies this level in the document hierarchy.
 * @param accessLevel The accumulated result.
 */
private void resolve(DocumentReference user,Collection<DocumentReference> groups,Collection<RightsObject> rightsObjects,EntityReference ref,AccessLevel accessLevel){
  AccessLevel currentLevel=new AccessLevel();
  Map<Right,Integer> priorities=new EnumMap(Right.class);
  for (  Right right : enabledRights.get(ref.getType())) {
    boolean foundAllow=false;
    for (    RightsObject obj : rightsObjects) {
      if (obj.checkRight(right)) {
        resolveLevel(right,user,groups,obj,ref,priorities,currentLevel);
      }
    }
  }
  mergeLevels(currentLevel,accessLevel,ref);
}
 

Example 3

From project mdk, under directory /service/derby/src/main/java/uk/ac/ebi/mdk/service/loader/reaction/.

Source file: KEGGReactionLoader.java

  20 
vote

public Map<KEGGField,StringBuilder> readNext() throws IOException {
  StringBuilder sb=new StringBuilder(1000);
  Map<KEGGField,StringBuilder> map=new EnumMap(KEGGField.class);
  String line;
  KEGGField field=null;
  while ((line=reader.readLine()) != null && !line.equals("///")) {
    String key=line.substring(0,Math.min(line.length(),12)).trim();
    field=key.isEmpty() ? field : KEGGField.valueOf(key);
    if (filter.contains(field)) {
      if (!map.containsKey(field)) {
        map.put(field,new StringBuilder(500));
      }
      map.get(field).append(line.substring(12));
    }
  }
  return line == null ? null : map;
}
 

Example 4

From project AdminCmd, under directory /src/main/java/be/Balor/Player/.

Source file: FilePlayer.java

  19 
vote

@Override public Map<Type,Object> getPowers(){
  final Map<Type,Object> result=new EnumMap<Type,Object>(Type.class);
  for (  final Entry<String,Object> entry : powers.getValues(false).entrySet()) {
    final Type power=Type.matchType(entry.getKey());
    if (power == null || (power != null && power == Type.CUSTOM)) {
      continue;
    }
    result.put(power,entry.getValue());
  }
  return result;
}
 

Example 5

From project Android-Simple-Social-Sharing, under directory /SimpleSocialSharing/src/com/nostra13/socialsharing/twitter/extpack/winterwell/jtwitter/.

Source file: Message.java

  19 
vote

/** 
 * @param obj
 * @throws JSONException
 * @throws TwitterException
 */
Message(JSONObject obj) throws JSONException, TwitterException {
  id=obj.getLong("id");
  String _text=obj.getString("text");
  text=InternalUtils.unencode(_text);
  String c=InternalUtils.jsonGet("created_at",obj);
  createdAt=InternalUtils.parseDate(c);
  sender=new User(obj.getJSONObject("sender"),null);
  Object recip=obj.opt("recipient");
  if (recip instanceof JSONObject) {
    recipient=new User((JSONObject)recip,null);
  }
 else {
    recipient=null;
  }
  JSONObject jsonEntities=obj.optJSONObject("entities");
  if (jsonEntities != null) {
    entities=new EnumMap<Twitter.KEntityType,List<TweetEntity>>(KEntityType.class);
    for (    KEntityType type : KEntityType.values()) {
      List<TweetEntity> es=TweetEntity.parse(this,_text,type,jsonEntities);
      entities.put(type,es);
    }
  }
  Object _locn=Status.jsonGetLocn(obj);
  location=_locn == null ? null : _locn.toString();
  if (_locn instanceof Place) {
    place=(Place)_locn;
  }
}
 

Example 6

From project android_external_guava, under directory /src/com/google/common/collect/.

Source file: EnumBiMap.java

  19 
vote

@SuppressWarnings("unchecked") private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
  stream.defaultReadObject();
  keyType=(Class<K>)stream.readObject();
  valueType=(Class<V>)stream.readObject();
  setDelegates(new EnumMap<K,V>(keyType),new EnumMap<V,K>(valueType));
  Serialization.populateMap(this,stream);
}
 

Example 7

From project apb, under directory /modules/apb-base/src/apb/testrunner/.

Source file: CoverageBuilder.java

  19 
vote

private EnumMap<CoverageReport.Column,Integer> loadCoverageInfo(CoverageReport report){
  BufferedReader reader=null;
  try {
    reader=new BufferedReader(new FileReader(report.getOutputFile(outputDir)));
    String line=null;
    for (int i=0; i < 6 && (line=reader.readLine()) != null; i++) {
      ;
    }
    EnumMap<CoverageReport.Column,Integer> info=new EnumMap<CoverageReport.Column,Integer>(CoverageReport.Column.class);
    if (line != null) {
      for (      CoverageReport.Column o : report.getColumns()) {
        int p=line.indexOf('%');
        if (p != -1) {
          int val=Integer.parseInt(line.substring(0,p).trim());
          info.put(o,val);
          p=line.indexOf(')');
          line=line.substring(p + 2);
        }
      }
    }
    return info;
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
 finally {
    StreamUtils.close(reader);
  }
}
 

Example 8

From project Bukkit-Plugin-Utilties, under directory /src/main/java/de/xzise/.

Source file: MinecraftUtil.java

  19 
vote

public static <K extends Enum<K>,V>EnumMap<K,V> createEnumMap(Map<K,V> map,Class<K> keyType){
  if (map == null) {
    return new EnumMap<K,V>(keyType);
  }
 else {
    return new EnumMap<K,V>(map);
  }
}
 

Example 9

From project Clotho-Core, under directory /ClothoProject/ClothoCore/src/org/clothocore/util/basic/.

Source file: ImageSource.java

  19 
vote

/** 
 * Get an icon set in the form of ImageIcons
 * @param height  height in pixels of the desired icons
 * @return the HashMap
 */
public static Map<ObjType,ImageIcon> getObjectIconSet(int height){
  initiateImages();
  Map<ObjType,ImageIcon> out=new EnumMap<ObjType,ImageIcon>(ObjType.class);
  for (  ObjType type : ObjType.values()) {
    BufferedImage img=_objectImages.get(type);
    out.put(type,new ImageIcon(scaleBF(img,height)));
  }
  return out;
}
 

Example 10

From project CoinFlip, under directory /src/com/banasiak/coinflip/.

Source file: CoinFlip.java

  19 
vote

/** 
 * Called when the activity is first created.
 */
@Override public void onCreate(final Bundle savedInstanceState){
  Log.d(TAG,"onCreate()");
  super.onCreate(savedInstanceState);
  if (Settings.getSchemaVersion(this) != SCHEMA_VERSION) {
    Settings.resetAllPrefs(this);
    Settings.setSchemaVersion(this,SCHEMA_VERSION);
  }
  flipCounter=Settings.getFlipCount(this);
  headsCounter=Settings.getHeadsCount(this);
  tailsCounter=Settings.getTailsCount(this);
  setContentView(R.layout.main);
  initViews();
  initSounds();
  coinAnimationsMap=new EnumMap<CoinFlip.ResultState,AnimationDrawable>(ResultState.class);
  coinImagesMap=new EnumMap<CoinFlip.ResultState,Drawable>(ResultState.class);
  shaker=new ShakeListener(this);
  shaker.pause();
  shaker.setOnShakeListener(new ShakeListener.OnShakeListener(){
    public void onShake(){
      flipCoin();
    }
  }
);
  tableLayout.setOnClickListener(new OnClickListener(){
    public void onClick(    final View v){
      flipCoin();
    }
  }
);
  statsResetButton.setOnClickListener(new OnClickListener(){
    public void onClick(    final View v){
      resetStatistics();
    }
  }
);
}
 

Example 11

From project craftbook, under directory /vehicles/src/main/java/com/sk89q/craftbook/cart/.

Source file: MinecartManager.java

  19 
vote

public void reloadConfiguration(VehiclesConfiguration cfg){
  mechanisms=new EnumMap<Material,CartMechanism>(Material.class);
  mechanisms.put(cfg.matBoostMax,new CartBooster(100));
  mechanisms.put(cfg.matBoost25x,new CartBooster(1.25));
  mechanisms.put(cfg.matSlow20x,new CartBooster(0.8));
  mechanisms.put(cfg.matSlow50x,new CartBooster(0.5));
  mechanisms.put(cfg.matReverse,new CartReverser());
  mechanisms.put(cfg.matSorter,new CartSorter());
  mechanisms.put(cfg.matStation,new CartStation());
  mechanisms.put(cfg.matEjector,new CartEjector());
  mechanisms.put(cfg.matDeposit,new CartDeposit());
  mechanisms.put(cfg.matTeleport,new CartTeleporter());
  mechanisms.put(cfg.matDispenser,new CartDispenser());
  mechanisms.put(cfg.matMessager,new CartMessager(plugin));
  for (  Map.Entry<Material,CartMechanism> ent : mechanisms.entrySet())   ent.getValue().setMaterial(ent.getKey());
}
 

Example 12

From project Cyborg, under directory /src/main/java/com/alta189/cyborg/api/event/.

Source file: HandlerList.java

  19 
vote

/** 
 * Create a new handler list and initialize using EventPriority The HandlerList is then added to meta-list for use in bakeAll()
 */
public HandlerList(){
  handlerslots=new EnumMap<Order,ArrayList<ListenerRegistration>>(Order.class);
  for (  Order o : Order.values()) {
    handlerslots.put(o,new ArrayList<ListenerRegistration>());
  }
  alllists.add(this);
}
 

Example 13

From project enterprise, under directory /consistency-check/src/main/java/org/neo4j/consistency/checking/full/.

Source file: OwnerCheck.java

  19 
vote

private static Map<RecordType,ConcurrentMap<Long,DynamicOwner>> initialize(DynamicStore[] stores){
  EnumMap<RecordType,ConcurrentMap<Long,DynamicOwner>> map=new EnumMap<RecordType,ConcurrentMap<Long,DynamicOwner>>(RecordType.class);
  for (  DynamicStore store : stores) {
    map.put(store.type,new ConcurrentHashMap<Long,DynamicOwner>(16,0.75f,4));
  }
  return unmodifiableMap(map);
}
 

Example 14

From project examples_1, under directory /trivial-calc/calc/src/com/paremus/dosgi/examples/calculator/cmd/.

Source file: Population.java

  19 
vote

public Map<Statistic,Number> statistics(Statistic... stats){
  Map<Statistic,Number> m=new EnumMap<Statistic,Number>(Statistic.class);
  for (  Statistic s : stats) {
    m.put(s,s.valueFor(this));
  }
  return m;
}
 

Example 15

From project Foglyn, under directory /com.foglyn.ui/src/com/foglyn/ui/.

Source file: FoglynRepositorySettingsPage.java

  19 
vote

@Override protected void createAdditionalControls(Composite parent){
  Label workingOnLabel=new Label(parent,SWT.NONE);
  workingOnLabel.setText("'Working On' synchronization:");
  workingOn=new Button(parent,SWT.CHECK);
  workingOn.setText("Synchronize active tasks with FogBugz");
  Boolean workingOnEnabled=com.foglyn.core.Utils.isWorkingOnSynchronizationEnabled(repository);
  if (workingOnEnabled == null) {
    workingOnEnabled=FoglynUIPlugin.getDefault().isWorkingOnSynchronizationEnabled();
  }
  workingOn.setSelection(workingOnEnabled.booleanValue());
  Label additional=new Label(parent,SWT.NONE);
  additional.setText("Case is marked as Complete when:");
  completedModeViewer=new ComboViewer(parent,SWT.DROP_DOWN | SWT.READ_ONLY);
  completedModeViewer.setContentProvider(new CollectionContentProvider(false));
  Map<CompletedCaseMode,String> labels=new EnumMap<CompletedCaseMode,String>(CompletedCaseMode.class);
  labels.put(CompletedCaseMode.CLOSED,"Closed");
  labels.put(CompletedCaseMode.RESOLVED_OR_CLOSED,"Closed or Resolved");
  labels.put(CompletedCaseMode.SMART_RESOLVED_OR_CLOSED,"Closed if mine, Resolved or Closed otherwise");
  completedModeViewer.setLabelProvider(new MapLabelProvider(labels,Collections.<Object,Image>emptyMap()));
  completedModeViewer.setInput(Arrays.asList(CompletedCaseMode.values()));
  completedModeViewer.setSelection(new StructuredSelection(com.foglyn.core.Utils.getCompletedCaseMode(repository)));
  completedModeViewer.getCombo().setVisibleItemCount(Constants.NUMBER_OF_ENTRIES_IN_COMBOBOX);
  GridDataFactory.defaultsFor(workingOnLabel).align(SWT.END,SWT.CENTER).applyTo(workingOnLabel);
  GridDataFactory.defaultsFor(workingOn).applyTo(workingOn);
  GridDataFactory.defaultsFor(additional).align(SWT.END,SWT.CENTER).applyTo(additional);
  GridDataFactory.defaultsFor(completedModeViewer.getControl()).applyTo(completedModeViewer.getControl());
}
 

Example 16

From project gs-core, under directory /src/org/graphstream/stream/.

Source file: AnnotatedSink.java

  19 
vote

protected AnnotatedSink(){
  methods=new EnumMap<ElementType,MethodMap>(ElementType.class);
  methods.put(ElementType.GRAPH,new MethodMap());
  methods.put(ElementType.EDGE,new MethodMap());
  methods.put(ElementType.NODE,new MethodMap());
  Method[] ms=getClass().getMethods();
  if (ms != null) {
    for (int i=0; i < ms.length; i++) {
      Method m=ms[i];
      Bind b=m.getAnnotation(Bind.class);
      if (b != null)       methods.get(b.type()).put(b.value(),m);
    }
  }
}
 

Example 17

From project jaffl, under directory /src/com/kenai/jaffl/provider/.

Source file: AbstractRuntime.java

  19 
vote

public AbstractRuntime(ByteOrder byteOrder,EnumMap<NativeType,Type> typeMap){
  this.byteOrder=byteOrder;
  EnumSet<NativeType> nativeTypes=EnumSet.allOf(NativeType.class);
  types=new Type[nativeTypes.size()];
  for (  NativeType t : nativeTypes) {
    types[t.ordinal()]=typeMap.containsKey(t) ? typeMap.get(t) : new BadType(t);
  }
  this.addressSize=types[NativeType.ADDRESS.ordinal()].size();
  this.longSize=types[NativeType.SLONG.ordinal()].size();
  this.addressMask=addressSize == 4 ? 0xffffffffL : 0xffffffffffffffffL;
}
 

Example 18

From project jboss-logging-tools, under directory /src/main/java/org/jboss/logging/processor/apt/.

Source file: MessageMethodBuilder.java

  19 
vote

/** 
 * Private constructor for the
 * @param elements    the elements utility.
 * @param method      the method to describe.
 * @param annotations the annotations
 */
AptMessageMethod(final Elements elements,final ExecutableElement method,final Annotations annotations){
  this.annotations=annotations;
  this.elements=elements;
  this.method=method;
  inheritsMessage=false;
  isOverloaded=false;
  parameters=new EnumMap<ParameterType,Set<Parameter>>(ParameterType.class);
  thrownTypes=new LinkedHashSet<ThrowableType>();
}
 

Example 19

From project jdg, under directory /infinispan/src/main/java/org/jboss/as/clustering/infinispan/subsystem/.

Source file: CacheAdd.java

  19 
vote

public static synchronized Configuration getDefaultConfiguration(CacheMode cacheMode){
  if (defaults == null) {
    ConfigurationBuilderHolder holder=load(DEFAULTS);
    Configuration defaultConfig=holder.getDefaultConfigurationBuilder().build();
    Map<CacheMode,Configuration> map=new EnumMap<CacheMode,Configuration>(CacheMode.class);
    map.put(defaultConfig.clustering().cacheMode(),defaultConfig);
    for (    ConfigurationBuilder builder : holder.getNamedConfigurationBuilders().values()) {
      Configuration config=builder.build();
      map.put(config.clustering().cacheMode(),config);
    }
    for (    CacheMode mode : CacheMode.values()) {
      if (!map.containsKey(mode)) {
        map.put(mode,new ConfigurationBuilder().read(defaultConfig).clustering().cacheMode(mode).build());
      }
    }
    defaults=map;
  }
  return defaults.get(cacheMode);
}
 

Example 20

From project jesque, under directory /src/main/java/net/greghaines/jesque/worker/.

Source file: WorkerListenerDelegate.java

  19 
vote

/** 
 * Create a new WorkerListenerDelegate.
 */
public WorkerListenerDelegate(){
  final Map<WorkerEvent,ConcurrentSet<WorkerListener>> elp=new EnumMap<WorkerEvent,ConcurrentSet<WorkerListener>>(WorkerEvent.class);
  for (  final WorkerEvent event : WorkerEvent.values()) {
    elp.put(event,new ConcurrentHashSet<WorkerListener>());
  }
  this.eventListenerMap=Collections.unmodifiableMap(elp);
}
 

Example 21

From project LateralGM, under directory /org/lateralgm/components/visual/.

Source file: RoomEditor.java

  19 
vote

public RoomEditor(Room r,RoomFrame frame){
  if (r.get(PRoom.REMEMBER_WINDOW_SIZE)) {
    EnumMap<PRoomEditor,Object> m=new EnumMap<PRoomEditor,Object>(PRoomEditor.class);
    for (    PRoomEditor pre : PRoomEditor.values())     try {
      m.put(pre,r.get(PRoom.valueOf(pre.toString())));
    }
 catch (    IllegalArgumentException e) {
      m.put(pre,DEFS.get(pre));
    }
    properties=new PropertyMap<PRoomEditor>(PRoomEditor.class,repv,m);
  }
 else   properties=new PropertyMap<PRoomEditor>(PRoomEditor.class,repv,DEFS);
  room=r;
  this.frame=frame;
  zoomOrigin=ORIGIN_MOUSE;
  r.properties.updateSource.addListener(rpl);
  enableEvents(MouseEvent.MOUSE_EVENT_MASK | MouseEvent.MOUSE_MOTION_EVENT_MASK);
  EnumSet<RoomVisual.Show> s=EnumSet.noneOf(RoomVisual.Show.class);
  for (  PRoomEditor p : PRoomEditor.values())   if (p.rvBinding != null && (Boolean)properties.get(p))   s.add(p.rvBinding);
  lockBounds();
  roomVisual=new RoomVisual(container,r,s);
  unlockBounds();
  put(0,roomVisual);
  setZoom((Integer)properties.get(PRoomEditor.ZOOM));
  refresh();
}
 

Example 22

From project leveldb, under directory /leveldb/src/test/java/org/iq80/leveldb/.

Source file: DbBenchmark.java

  19 
vote

public static void main(String[] args) throws Exception {
  Map<Flag,Object> flags=new EnumMap<Flag,Object>(Flag.class);
  for (  Flag flag : Flag.values()) {
    flags.put(flag,flag.getDefaultValue());
  }
  for (  String arg : args) {
    boolean valid=false;
    if (arg.startsWith("--")) {
      try {
        ImmutableList<String> parts=ImmutableList.copyOf(Splitter.on("=").limit(2).split(arg.substring(2)));
        if (parts.size() != 2) {
        }
        Flag key=Flag.valueOf(parts.get(0));
        Object value=key.parseValue(parts.get(1));
        flags.put(key,value);
        valid=true;
      }
 catch (      Exception e) {
      }
    }
    if (!valid) {
      System.err.println("Invalid argument " + arg);
      System.exit(1);
    }
  }
  new DbBenchmark(flags).run();
}
 

Example 23

From project linkedin-utils, under directory /org.linkedin.util-core/src/main/java/org/linkedin/util/clock/.

Source file: Timespan.java

  19 
vote

/** 
 * Decomposes this timespan as a map for each unit provided. Example: if this timespan represents 63s and you provide m/s/ms then you will get 3 timespans in the map: one of 1mn, one for 3s and one for 0ms.
 * @param timeUnits the time units you want to be part of the decomposition.
 * @return a map containing an entry for each time unit provided. All others are <code>null</code>.
 */
public EnumMap<TimeUnit,Timespan> getAsTimespans(EnumSet<TimeUnit> timeUnits){
  EnumMap<TimeUnit,Timespan> res=new EnumMap<TimeUnit,Timespan>(TimeUnit.class);
  long durationInMillis=getDurationInMilliseconds();
  for (  TimeUnit timeUnit : TIME_UNIT_ORDER) {
    if (timeUnits.contains(timeUnit)) {
      Timespan timespan=truncateDurationToUnit(durationInMillis,timeUnit);
      res.put(timeUnit,timespan);
      durationInMillis-=timespan.getDurationInMilliseconds();
    }
  }
  return res;
}
 

Example 24

From project Mafiacraft, under directory /src/main/java/net/voxton/mafiacraft/core/gov/.

Source file: Government.java

  19 
vote

/** 
 * Gets a map of all positions.
 * @return
 */
public Map<Position,Set<String>> getPositions(){
  Map<Position,Set<String>> positions=new EnumMap<Position,Set<String>>(Position.class);
  for (  Position position : Position.values()) {
    positions.put(position,getMembers(position));
  }
  return positions;
}
 

Example 25

From project milton, under directory /milton/milton-api/src/main/java/com/bradmcevoy/http/values/.

Source file: PriviledgeListValueWriter.java

  19 
vote

private static Map<Priviledge,String> initPriviledgeToStringMap(){
  Map<Priviledge,String> map=new EnumMap<Priviledge,String>(Priviledge.class);
  map.put(Priviledge.READ,"read");
  map.put(Priviledge.WRITE,"write");
  map.put(Priviledge.READ_ACL,"read-acl");
  map.put(Priviledge.WRITE_ACL,"write-acl");
  map.put(Priviledge.UNLOCK,"unlock");
  map.put(Priviledge.READ_CURRENT_USER_PRIVILEDGE,"read-current-user-privilege-set");
  map.put(Priviledge.WRITE_PROPERTIES,"write-properties");
  map.put(Priviledge.WRITE_CONTENT,"write-content");
  map.put(Priviledge.BIND,"bind");
  map.put(Priviledge.UNBIND,"unbind");
  map.put(Priviledge.ALL,"all");
  return map;
}
 

Example 26

From project milton2, under directory /milton-server/src/main/java/io/milton/http/values/.

Source file: PriviledgeListValueWriter.java

  19 
vote

private static Map<Priviledge,String> initPriviledgeToStringMap(){
  Map<Priviledge,String> map=new EnumMap<Priviledge,String>(Priviledge.class);
  map.put(Priviledge.READ,"read");
  map.put(Priviledge.WRITE,"write");
  map.put(Priviledge.READ_ACL,"read-acl");
  map.put(Priviledge.WRITE_ACL,"write-acl");
  map.put(Priviledge.UNLOCK,"unlock");
  map.put(Priviledge.READ_CURRENT_USER_PRIVILEDGE,"read-current-user-privilege-set");
  map.put(Priviledge.WRITE_PROPERTIES,"write-properties");
  map.put(Priviledge.WRITE_CONTENT,"write-content");
  map.put(Priviledge.BIND,"bind");
  map.put(Priviledge.UNBIND,"unbind");
  map.put(Priviledge.ALL,"all");
  return map;
}
 

Example 27

From project Mobile-Tour-Guide, under directory /zxing-2.0/android/src/com/google/zxing/client/android/.

Source file: DecodeThread.java

  19 
vote

DecodeThread(CaptureActivity activity,Collection<BarcodeFormat> decodeFormats,String characterSet,ResultPointCallback resultPointCallback){
  this.activity=activity;
  handlerInitLatch=new CountDownLatch(1);
  hints=new EnumMap<DecodeHintType,Object>(DecodeHintType.class);
  if (decodeFormats == null || decodeFormats.isEmpty()) {
    SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(activity);
    decodeFormats=EnumSet.noneOf(BarcodeFormat.class);
    if (prefs.getBoolean(PreferencesActivity.KEY_DECODE_1D,false)) {
      decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS);
    }
    if (prefs.getBoolean(PreferencesActivity.KEY_DECODE_QR,false)) {
      decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS);
    }
    if (prefs.getBoolean(PreferencesActivity.KEY_DECODE_DATA_MATRIX,false)) {
      decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS);
    }
  }
  hints.put(DecodeHintType.POSSIBLE_FORMATS,decodeFormats);
  if (characterSet != null) {
    hints.put(DecodeHintType.CHARACTER_SET,characterSet);
  }
  hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK,resultPointCallback);
}
 

Example 28

From project platform_external_guava, under directory /src/com/google/common/collect/.

Source file: EnumBiMap.java

  19 
vote

@SuppressWarnings("unchecked") private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
  stream.defaultReadObject();
  keyType=(Class<K>)stream.readObject();
  valueType=(Class<V>)stream.readObject();
  setDelegates(new EnumMap<K,V>(keyType),new EnumMap<V,K>(valueType));
  Serialization.populateMap(this,stream);
}
 

Example 29

From project psl, under directory /psl-core/src/main/java/edu/umd/cs/psl/model/atom/memory/.

Source file: MemoryAtomEventFramework.java

  19 
vote

public MemoryAtomEventFramework(ModelApplication application,AtomStore store,ActivationMode activemode){
  this.application=application;
  this.store=store;
  atomjobs=new LinkedList<AtomJob>();
  activationMode=activemode;
  groundingMode=GroundingMode.defaultGroundingMode;
  atomObservers=new EnumMap<AtomEvent,SetMultimap<Predicate,AtomEventObserver>>(AtomEvent.class);
  for (  AtomEvent ae : AtomEvent.values()) {
    SetMultimap<Predicate,AtomEventObserver> map=HashMultimap.create();
    atomObservers.put(ae,map);
  }
}
 

Example 30

From project SimpleMoney-Android, under directory /Zxing/bin/src/com/google/zxing/client/android/.

Source file: DecodeThread.java

  19 
vote

DecodeThread(CaptureActivity activity,Collection<BarcodeFormat> decodeFormats,String characterSet,ResultPointCallback resultPointCallback){
  this.activity=activity;
  handlerInitLatch=new CountDownLatch(1);
  hints=new EnumMap<DecodeHintType,Object>(DecodeHintType.class);
  if (decodeFormats == null || decodeFormats.isEmpty()) {
    SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(activity);
    decodeFormats=EnumSet.noneOf(BarcodeFormat.class);
    if (prefs.getBoolean(PreferencesActivity.KEY_DECODE_1D,false)) {
      decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS);
    }
    if (prefs.getBoolean(PreferencesActivity.KEY_DECODE_QR,false)) {
      decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS);
    }
    if (prefs.getBoolean(PreferencesActivity.KEY_DECODE_DATA_MATRIX,false)) {
      decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS);
    }
  }
  hints.put(DecodeHintType.POSSIBLE_FORMATS,decodeFormats);
  if (characterSet != null) {
    hints.put(DecodeHintType.CHARACTER_SET,characterSet);
  }
  hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK,resultPointCallback);
}
 

Example 31

From project smart-cms, under directory /api-modules/content-type-xml/src/main/java/com/smartitengineering/cms/type/xml/.

Source file: XmlParser.java

  19 
vote

private Map<ContentProcessingPhase,List<MutableContentCoProcessorDef>> parseContentCoProcessorDefs(Element contentTypeElement,String elementName){
  Elements elems=contentTypeElement.getChildElements(elementName,NAMESPACE);
  if (elems.size() > 1) {
    throw new IllegalStateException("More than one " + elementName);
  }
  Map<ContentProcessingPhase,List<MutableContentCoProcessorDef>> result=new EnumMap<ContentProcessingPhase,List<MutableContentCoProcessorDef>>(ContentProcessingPhase.class);
  if (elems.size() > 0) {
    Elements elements=elems.get(0).getChildElements(CONTENT_CO_PROCESSOR_READ_PHASE,NAMESPACE);
    if (elements != null && elements.size() > 0) {
      List<MutableContentCoProcessorDef> readProcs=parseContentCoProcessors(elements.get(0),CONTENT_CO_PROCESSORS);
      result.put(ContentProcessingPhase.READ,readProcs);
    }
    elements=elems.get(0).getChildElements(CONTENT_CO_PROCESSOR_WRITE_PHASE,NAMESPACE);
    if (elements != null && elements.size() > 0) {
      List<MutableContentCoProcessorDef> writeProcs=parseContentCoProcessors(elements.get(0),CONTENT_CO_PROCESSORS);
      result.put(ContentProcessingPhase.WRITE,writeProcs);
    }
  }
  if (logger.isDebugEnabled()) {
    logger.debug("Returning co processors " + result);
  }
  return result;
}
 

Example 32

From project Sourcerer, under directory /infrastructure/tools/java/database-importer/src/edu/uci/ics/sourcerer/tools/java/db/importer/.

Source file: EntitiesImporter.java

  19 
vote

private void insertFileAndProjectMetrics(ReaderBundle reader,Integer projectID){
  task.start("Inserting file metrics");
  task.start("Processing files","files processed");
  BatchInserter inserter=exec.makeInFileInserter(tempDir,FileMetricsTable.TABLE);
  Map<Metric,AtomicDouble> projectMetrics=new EnumMap<>(Metric.class);
  for (  FileEX file : reader.getTransientFiles()) {
    if (file.getType() == File.SOURCE || file.getType() == File.CLASS) {
      Integer fileID=fileMap.get(file.getPath());
      if (fileID == null) {
        task.report(Level.SEVERE,"Unknown file: " + file.getPath());
      }
 else {
        Metrics metrics=file.getMetrics();
        if (metrics != null) {
          for (          Entry<Metric,Double> metric : metrics.getMetricValues()) {
            AtomicDouble d=projectMetrics.get(metric.getKey());
            if (d == null) {
              d=new AtomicDouble(metric.getValue().doubleValue());
              projectMetrics.put(metric.getKey(),d);
            }
 else {
              d.addAndGet(metric.getValue().doubleValue());
            }
            inserter.addInsert(FileMetricsTable.createInsert(projectID,fileID,metric.getKey(),metric.getValue()));
          }
        }
      }
      task.progress();
    }
  }
  task.finish();
  task.start("Performing db insert");
  inserter.insert();
  for (  Map.Entry<Metric,AtomicDouble> entry : projectMetrics.entrySet()) {
    exec.insert(ProjectMetricsTable.createInsert(projectID,entry.getKey(),entry.getValue().doubleValue()));
  }
  task.finish();
  task.finish();
}
 

Example 33

From project SpoutAPI, under directory /src/main/java/org/spout/api/event/.

Source file: HandlerList.java

  19 
vote

/** 
 * Create a new handler list and initialize using EventPriority The HandlerList is then added to meta-list for use in bakeAll()
 */
public HandlerList(){
  handlerSlots=new EnumMap<Order,List<ListenerRegistration>>(Order.class);
  for (  Order o : Order.values()) {
    handlerSlots.put(o,new ArrayList<ListenerRegistration>());
  }
  ALL_LISTS.add(this);
}
 

Example 34

From project SpoutcraftAPI, under directory /src/main/java/org/spoutcraft/spoutcraftapi/event/.

Source file: HandlerList.java

  19 
vote

/** 
 * Create a new handler list and initialize using EventManager.Order handlerlist is then added to meta-list for use in bakeall()
 */
public HandlerList(){
  handlerslots=new EnumMap<Order,ArrayList<ListenerRegistration<TEvent>>>(Order.class);
  for (  Order o : Order.values()) {
    handlerslots.put(o,new ArrayList<ListenerRegistration<TEvent>>());
  }
  alllists.add(this);
}
 

Example 35

From project Starfish, under directory /starfish/src/profile/edu/duke/starfish/profile/profileinfo/execution/profile/.

Source file: MRExecProfile.java

  19 
vote

/** 
 * Copy constructor
 * @param other an execution profile to copy from
 */
public MRExecProfile(MRExecProfile other){
  this();
  if (other.counters != null)   this.counters=new EnumMap<MRCounter,Long>(other.counters);
  if (other.stats != null)   this.stats=new EnumMap<MRStatistics,Double>(other.stats);
  if (other.costs != null)   this.costs=new EnumMap<MRCostFactors,Double>(other.costs);
  if (other.auxCounters != null)   this.auxCounters=new HashMap<String,Long>(other.auxCounters);
}
 

Example 36

From project streetlights, under directory /streetlights-client-android/simple-xml-2.6.3/test/src/org/simpleframework/xml/core/.

Source file: EnumMapTest.java

  19 
vote

public void testEnumMap() throws Exception {
  EnumMap<Number,String> numbers=new EnumMap<Number,String>(Number.class);
  numbers.put(Number.ONE,"1");
  numbers.put(Number.TWO,"2");
  numbers.put(Number.THREE,"3");
  EnumMapExample example=new EnumMapExample(numbers);
  Persister persister=new Persister();
  StringWriter out=new StringWriter();
  persister.write(example,System.out);
  persister.write(example,out);
  EnumMapExample other=persister.read(EnumMapExample.class,out.toString());
  assertEquals(other.get(Number.ONE),"1");
  assertEquals(other.get(Number.TWO),"2");
  assertEquals(other.get(Number.THREE),"3");
  assertEquals(other.get(Number.FOUR),null);
  persister.write(example,System.out);
  validate(persister,example);
}
 

Example 37

From project SWADroid, under directory /SWADroid/src/com/google/zxing/client/android/.

Source file: DecodeThread.java

  19 
vote

DecodeThread(CaptureActivity activity,Collection<BarcodeFormat> decodeFormats,String characterSet,ResultPointCallback resultPointCallback){
  this.activity=activity;
  handlerInitLatch=new CountDownLatch(1);
  hints=new EnumMap<DecodeHintType,Object>(DecodeHintType.class);
  if (decodeFormats == null || decodeFormats.isEmpty()) {
    SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(activity);
    decodeFormats=EnumSet.noneOf(BarcodeFormat.class);
    if (prefs.getBoolean(PreferencesActivity.KEY_DECODE_1D,false)) {
      decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS);
    }
    if (prefs.getBoolean(PreferencesActivity.KEY_DECODE_QR,false)) {
      decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS);
    }
    if (prefs.getBoolean(PreferencesActivity.KEY_DECODE_DATA_MATRIX,false)) {
      decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS);
    }
  }
  hints.put(DecodeHintType.POSSIBLE_FORMATS,decodeFormats);
  if (characterSet != null) {
    hints.put(DecodeHintType.CHARACTER_SET,characterSet);
  }
  hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK,resultPointCallback);
}
 

Example 38

From project TeraSpout, under directory /src/main/java/org/terasology/model/blocks/.

Source file: AlignToSurfaceFamily.java

  19 
vote

/** 
 * @param name   The name for the block group.
 * @param blocks The set of blocks that make up the group. Front, Back, Left and Right must be provided - the rest is ignored.
 */
public AlignToSurfaceFamily(String name,EnumMap<Side,TeraBlock> blocks){
  _name=name;
  for (  Side side : Side.values()) {
    TeraBlock block=blocks.get(side);
    if (block != null) {
      _blocks.put(side,block);
      block.withBlockFamily(this);
    }
  }
  if (_blocks.containsKey(Side.TOP)) {
    _archetype=_blocks.get(Side.TOP);
  }
 else {
    _archetype=_blocks.get(Side.FRONT);
  }
}
 

Example 39

From project wharf, under directory /wharf-core/src/main/java/org/jfrog/wharf/ivy/resource/.

Source file: WharfUrlResource.java

  19 
vote

public WharfUrlResource(Resource resource){
  if (resource instanceof FileResource) {
    try {
      url=((FileResource)resource).getFile().toURI().toURL();
    }
 catch (    MalformedURLException e) {
      throw new IllegalArgumentException("Malformed File URL",e);
    }
    remote=new EnumMap<ChecksumType,String>(ChecksumType.class);
    actual=new EnumMap<ChecksumType,String>(ChecksumType.class);
  }
 else   if (resource instanceof URLResource) {
    url=((URLResource)resource).getURL();
    remote=new EnumMap<ChecksumType,String>(ChecksumType.class);
    actual=new EnumMap<ChecksumType,String>(ChecksumType.class);
  }
 else   if (resource instanceof WharfUrlResource) {
    WharfUrlResource wharfUrlResource=(WharfUrlResource)resource;
    this.url=wharfUrlResource.url;
    this.init=wharfUrlResource.init;
    this.lastModified=wharfUrlResource.lastModified;
    this.contentLength=wharfUrlResource.contentLength;
    this.exists=wharfUrlResource.exists;
    this.remote=new EnumMap<ChecksumType,String>(wharfUrlResource.remote);
    this.actual=new EnumMap<ChecksumType,String>(wharfUrlResource.actual);
  }
 else {
    throw new IllegalArgumentException("Wharf Downloader manage only URL and Files");
  }
}
 

Example 40

From project zxing, under directory /android/src/com/google/zxing/client/android/.

Source file: DecodeThread.java

  19 
vote

DecodeThread(CaptureActivity activity,Collection<BarcodeFormat> decodeFormats,String characterSet,ResultPointCallback resultPointCallback){
  this.activity=activity;
  handlerInitLatch=new CountDownLatch(1);
  hints=new EnumMap<DecodeHintType,Object>(DecodeHintType.class);
  if (decodeFormats == null || decodeFormats.isEmpty()) {
    SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(activity);
    decodeFormats=EnumSet.noneOf(BarcodeFormat.class);
    if (prefs.getBoolean(PreferencesActivity.KEY_DECODE_1D,false)) {
      decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS);
    }
    if (prefs.getBoolean(PreferencesActivity.KEY_DECODE_QR,false)) {
      decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS);
    }
    if (prefs.getBoolean(PreferencesActivity.KEY_DECODE_DATA_MATRIX,false)) {
      decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS);
    }
  }
  hints.put(DecodeHintType.POSSIBLE_FORMATS,decodeFormats);
  if (characterSet != null) {
    hints.put(DecodeHintType.CHARACTER_SET,characterSet);
  }
  hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK,resultPointCallback);
}