Java Code Examples for java.util.LinkedHashMap
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 action-core, under directory /src/main/java/com/ning/metrics/action/endpoint/.
Source file: HdfsBrowser.java

@GET @Produces(MediaType.APPLICATION_JSON) @Path("/viewer") @Timed public Response prettyPrintOneLine(@QueryParam("object") final String object) throws IOException { final ByteArrayOutputStream out=new ByteArrayOutputStream(); final ObjectMapper mapper=new ObjectMapper(); final String objectURIDecoded=URLDecoder.decode(object,"UTF-8"); final byte[] objectBase64Decoded=Base64.decodeBase64(objectURIDecoded.getBytes()); mapper.configure(SerializationFeature.INDENT_OUTPUT,true); final LinkedHashMap map=mapper.readValue(new String(objectBase64Decoded),LinkedHashMap.class); mapper.writeValue(out,map); return Response.ok().entity(new String(out.toByteArray())).build(); }
Example 2
From project AdminCmd, under directory /src/main/java/be/Balor/Tools/Configuration/File/.
Source file: ExtendedRepresenter.java

@Override public Node representData(final Object data){ final ConfigurationSerializable serializable=(ConfigurationSerializable)data; final Map<String,Object> values=new LinkedHashMap<String,Object>(); values.put(ConfigurationSerialization.SERIALIZED_TYPE_KEY,ConfigurationSerialization.getAlias(serializable.getClass())); values.putAll(serializable.serialize()); return super.representData(values); }
Example 3
From project android_5, under directory /src/aarddict/android/.
Source file: DictionaryService.java

@SuppressWarnings("unchecked") public Map<UUID,List<Volume>> getVolumes(){ Map<UUID,List<Volume>> result=new LinkedHashMap(); for ( Volume d : library) { UUID dictionaryId=d.getDictionaryId(); if (!result.containsKey(dictionaryId)) { result.put(dictionaryId,new ArrayList<Volume>()); } result.get(dictionaryId).add(d); } return result; }
Example 4
From project blacktie, under directory /stompconnect-1.0/src/main/java/org/codehaus/stomp/util/.
Source file: IntrospectionSupport.java

private static String toString(Object target,Class stopClass) throws IllegalArgumentException, IllegalAccessException { LinkedHashMap map=new LinkedHashMap(); IntrospectionSupport.addFields(target,target.getClass(),stopClass,map); StringBuffer buffer=new StringBuffer(IntrospectionSupport.simpleName(target.getClass())); buffer.append(" {"); Set entrySet=map.entrySet(); boolean first=true; for (Iterator iter=entrySet.iterator(); iter.hasNext(); ) { Map.Entry entry=(Map.Entry)iter.next(); if (first) { first=false; } else { buffer.append(", "); } buffer.append(entry.getKey()); buffer.append(" = "); buffer.append(entry.getValue()); } buffer.append("}"); return buffer.toString(); }
Example 5
From project chromattic, under directory /core/src/main/java/org/chromattic/core/query/.
Source file: QueryBuilderImpl.java

public QueryBuilder<O> orderBy(String orderByProperty,Ordering orderBy) throws NullPointerException { if (orderByProperty == null) { throw new NullPointerException(); } if (orderBy == null) { throw new NullPointerException(); } if (orderByMap == null) { orderByMap=new LinkedHashMap<String,Ordering>(); } orderByMap.put(orderByProperty,orderBy); return this; }
Example 6
From project activemq-apollo, under directory /apollo-util/src/main/scala/org/apache/activemq/apollo/util/.
Source file: Combinator.java

private void expandCombinations(List<ComboOption> optionsLeft,List<Map<String,Object>> expandedCombos){ if (!optionsLeft.isEmpty()) { Map<String,Object> map; if (comboOptions.size() == optionsLeft.size()) { map=new LinkedHashMap<String,Object>(); expandedCombos.add(map); } else { map=expandedCombos.get(expandedCombos.size() - 1); } LinkedList<ComboOption> l=new LinkedList<ComboOption>(optionsLeft); ComboOption comboOption=l.removeFirst(); int i=0; for (Iterator<Object> iter=comboOption.values.iterator(); iter.hasNext(); ) { Object value=iter.next(); if (i != 0) { map=new LinkedHashMap<String,Object>(map); expandedCombos.add(map); } map.put(comboOption.attribute,value); expandCombinations(l,expandedCombos); i++; } } }
Example 7
From project activiti-explorer, under directory /src/main/java/org/activiti/explorer/util/.
Source file: UriUtility.java

/** * Parses the parameters from the given url query string. When no encoding is passed, default UTF-8 is used. Based on the implementation in Commons httpclient UrlEncodedUtils. */ public static Map<String,String> parseQueryParameters(String queryString,String encoding){ Map<String,String> parameters=new LinkedHashMap<String,String>(); if (queryString != null) { if (queryString.startsWith(QUERY_STRING_SEPARATOR)) { queryString=queryString.substring(1); } Scanner scanner=new Scanner(queryString); scanner.useDelimiter(PARAMETER_SEPARATOR); while (scanner.hasNext()) { final String[] nameValue=scanner.next().split(NAME_VALUE_SEPARATOR); if (nameValue.length == 0 || nameValue.length > 2) throw new IllegalArgumentException("bad parameter"); final String name=decode(nameValue[0],encoding); String value=null; if (nameValue.length == 2) { value=decode(nameValue[1],encoding); } parameters.put(name,value); } } return parameters; }
Example 8
From project addis, under directory /application/src/main/java/org/drugis/addis/util/jaxb/.
Source file: JAXBConvertor.java

public static LinkedHashMap<String,org.drugis.addis.entities.StudyOutcomeMeasure<?>> convertStudyOutcomeMeasures(StudyOutcomeMeasures oms,List<Epoch> epochs,Domain domain) throws ConversionException { LinkedHashMap<String,StudyOutcomeMeasure<?>> map=new LinkedHashMap<String,StudyOutcomeMeasure<?>>(); for ( org.drugis.addis.entities.data.StudyOutcomeMeasure om : oms.getStudyOutcomeMeasure()) { org.drugis.addis.entities.StudyOutcomeMeasure<?> convOm=convertStudyOutcomeMeasure(om,epochs,domain); map.put(om.getId(),convOm); } return map; }
Example 9
From project advanced, under directory /management/src/main/java/org/neo4j/management/impl/jconsole/.
Source file: Neo4jPlugin.java

@Override public Map<String,JPanel> getTabs(){ ManagementAccess[] managers=ManagementAccess.getAll(getContext().getMBeanServerConnection()); Map<String,JPanel> result=new LinkedHashMap<String,JPanel>(); if (managers.length == 1) { addTabs(managers[0],"",result); } else { for ( ManagementAccess manager : managers) { addTabs(manager," (" + manager.getMBeanQuery().getKeyProperty("instance") + ")",result); } } return result; }
Example 10
From project aether-ant, under directory /src/main/java/org/eclipse/aether/ant/.
Source file: AntRepoSys.java

public RepositorySystemSession getSession(Task task,LocalRepository localRepo){ DefaultRepositorySystemSession session=MavenRepositorySystemUtils.newSession(); Map<Object,Object> configProps=new LinkedHashMap<Object,Object>(); configProps.put(ConfigurationProperties.USER_AGENT,getUserAgent()); configProps.putAll(System.getProperties()); configProps.putAll((Map<?,?>)project.getProperties()); configProps.putAll((Map<?,?>)project.getUserProperties()); session.setConfigProperties(configProps); session.setOffline(isOffline()); session.setUserProperties(project.getUserProperties()); session.setLocalRepositoryManager(getLocalRepoMan(localRepo)); session.setProxySelector(getProxySelector()); session.setMirrorSelector(getMirrorSelector()); session.setAuthenticationSelector(getAuthSelector()); session.setCache(new DefaultRepositoryCache()); session.setRepositoryListener(new AntRepositoryListener(task)); session.setTransferListener(new AntTransferListener(task)); session.setWorkspaceReader(ProjectWorkspaceReader.getInstance()); return session; }
Example 11
From project aether-core, under directory /aether-connector-asynchttpclient/src/main/java/org/eclipse/aether/connector/async/.
Source file: AsyncRepositoryConnector.java

/** * Create an {@link org.eclipse.aether.connector.async.AsyncRepositoryConnector} instance which connect to the{@link RemoteRepository} * @param repository the remote repository * @param session the {@link RepositorySystemSession} * @param logger the logger. * @throws NoRepositoryConnectorException */ public AsyncRepositoryConnector(RemoteRepository repository,RepositorySystemSession session,FileProcessor fileProcessor,Logger logger) throws NoRepositoryConnectorException { if (!"default".equals(repository.getContentType())) { throw new NoRepositoryConnectorException(repository); } if (!repository.getProtocol().regionMatches(true,0,"http",0,"http".length()) && !repository.getProtocol().regionMatches(true,0,"dav",0,"dav".length())) { throw new NoRepositoryConnectorException(repository); } this.logger=logger; this.repository=repository; this.listener=session.getTransferListener(); this.fileProcessor=fileProcessor; this.session=session; repoAuthContext=AuthenticationContext.forRepository(session,repository); proxyAuthContext=AuthenticationContext.forProxy(session,repository); AsyncHttpClientConfig config=createConfig(session,repository,true); httpClient=new AsyncHttpClient(getProvider(session,config),config); checksumAlgos=new LinkedHashMap<String,String>(); checksumAlgos.put("SHA-1",".sha1"); checksumAlgos.put("MD5",".md5"); disableResumeSupport=ConfigUtils.getBoolean(session,false,"aether.connector.ahc.disableResumable"); maxIOExceptionRetry=ConfigUtils.getInteger(session,3,"aether.connector.ahc.resumeRetry"); this.headers=new FluentCaseInsensitiveStringsMap(); Map<?,?> headers=ConfigUtils.getMap(session,null,ConfigurationProperties.HTTP_HEADERS + "." + repository.getId(),ConfigurationProperties.HTTP_HEADERS); if (headers != null) { for ( Map.Entry<?,?> entry : headers.entrySet()) { if (entry.getKey() instanceof String && entry.getValue() instanceof String) { this.headers.add(entry.getKey().toString(),entry.getValue().toString()); } } } }
Example 12
From project agileBase, under directory /gtpb_server/src/com/gtwm/pb/model/manageData/.
Source file: DataManagement.java

public void cloneRecord(HttpServletRequest request,TableInfo table,int rowId,SessionDataInfo sessionData,List<FileItem> multipartItems) throws ObjectNotFoundException, SQLException, CantDoThatException, CodingErrorException, InputRecordException, DisallowedException, MissingParametersException { Map<BaseField,BaseValue> values=this.getTableDataRow(sessionData,table,rowId,false); LinkedHashMap<BaseField,BaseValue> valuesToClone=new LinkedHashMap<BaseField,BaseValue>(); SortedSet<BaseField> fields=table.getFields(); for ( BaseField field : fields) { if ((!(field instanceof FileField)) && (!(field instanceof SeparatorField)) && (!(field instanceof CommentFeedField))&& (!(field.getFieldName().equals(HiddenFields.COMMENTS_FEED.getFieldName())))&& (!(field instanceof ReferencedReportDataField))&& (!(field.getUnique()))) { if (field instanceof RelationField) { BaseValue relationValue=values.get(((RelationField)field).getRelatedField()); valuesToClone.put(field,relationValue); } else { valuesToClone.put(field,values.get(field)); } } } Set<Integer> rowIds=new HashSet<Integer>(); rowIds.add(-1); this.saveRecord(request,table,valuesToClone,true,rowIds,sessionData,multipartItems); }
Example 13
From project airlift, under directory /jmx-http/src/main/java/io/airlift/jmx/.
Source file: MBeanRepresentation.java

public MBeanRepresentation(MBeanServer mbeanServer,ObjectName objectName,ObjectMapper objectMapper) throws JMException { this.objectName=objectName; MBeanInfo mbeanInfo=mbeanServer.getMBeanInfo(objectName); className=mbeanInfo.getClassName(); description=mbeanInfo.getDescription(); descriptor=toMap(mbeanInfo.getDescriptor()); LinkedHashMap<String,MBeanAttributeInfo> attributeInfos=Maps.newLinkedHashMap(); for ( MBeanAttributeInfo attributeInfo : mbeanInfo.getAttributes()) { attributeInfos.put(attributeInfo.getName(),attributeInfo); } String[] attributeNames=attributeInfos.keySet().toArray(new String[attributeInfos.size()]); ImmutableList.Builder<AttributeRepresentation> attributes=ImmutableList.builder(); for ( Attribute attribute : mbeanServer.getAttributes(objectName,attributeNames).asList()) { String attributeName=attribute.getName(); MBeanAttributeInfo attributeInfo=attributeInfos.remove(attributeName); if (attributeInfo == null) { continue; } Object attributeValue=attribute.getValue(); AttributeRepresentation attributeRepresentation=new AttributeRepresentation(attributeInfo,attributeValue,objectMapper); attributes.add(attributeRepresentation); } this.attributes=attributes.build(); ImmutableList.Builder<OperationRepresentation> operations=ImmutableList.builder(); for ( MBeanOperationInfo operationInfo : mbeanInfo.getOperations()) { operations.add(new OperationRepresentation(operationInfo)); } this.operations=operations.build(); }
Example 14
From project amber, under directory /oauth-2.0/common/src/main/java/org/apache/amber/oauth2/common/parameters/.
Source file: QueryParameterApplier.java

public OAuthMessage applyOAuthParameters(OAuthMessage message,Map<String,Object> params){ String messageUrl=message.getLocationUri(); if (messageUrl != null) { boolean containsQuestionMark=messageUrl.contains("?"); StringBuffer url=new StringBuffer(messageUrl); Map<String,Object> fragmentParams=new LinkedHashMap<String,Object>(); if (params.containsKey(OAuth.OAUTH_ACCESS_TOKEN)) { fragmentParams.put(OAuth.OAUTH_ACCESS_TOKEN,params.remove(OAuth.OAUTH_ACCESS_TOKEN)); if (params.containsKey(OAuth.OAUTH_STATE)) { fragmentParams.put(OAuth.OAUTH_STATE,params.remove(OAuth.OAUTH_STATE)); } if (params.containsKey(OAuth.OAUTH_EXPIRES_IN)) { fragmentParams.put(OAuth.OAUTH_EXPIRES_IN,params.remove(OAuth.OAUTH_EXPIRES_IN)); } if (params.containsKey(OAuth.OAUTH_TOKEN_TYPE)) { fragmentParams.put(OAuth.OAUTH_TOKEN_TYPE,params.remove(OAuth.OAUTH_TOKEN_TYPE)); } } StringBuffer query=new StringBuffer(OAuthUtils.format(params.entrySet(),"UTF-8")); String fragmentQuery=""; if (fragmentParams.containsKey(OAuth.OAUTH_ACCESS_TOKEN)) { fragmentQuery=OAuthUtils.format(fragmentParams.entrySet(),"UTF-8"); } if (!OAuthUtils.isEmpty(query.toString())) { if (containsQuestionMark) { url.append("&").append(query); } else { url.append("?").append(query); } } if (!OAuthUtils.isEmpty(fragmentQuery)) { url.append("#").append(fragmentQuery); } message.setLocationUri(url.toString()); } return message; }
Example 15
From project amplafi-sworddance, under directory /src/main/java/com/sworddance/util/.
Source file: CUtilities.java

@SuppressWarnings("unchecked") private static <K,V>Map<K,V> createMap(boolean skipNullValues,Object... keysAndValues){ Map<K,V> map=new LinkedHashMap<K,V>(); if (keysAndValues != null && keysAndValues.length != 0) { if (keysAndValues.length % 2 != 0) { throw new ApplicationIllegalStateException("Non-even number of parameters to createMap. Need matched set of keys and values. got=",join(keysAndValues,",")); } for (int i=0; i < keysAndValues.length; i+=2) { if (keysAndValues[i] != null && (!skipNullValues || keysAndValues[i + 1] != null)) { map.put((K)keysAndValues[i],(V)keysAndValues[i + 1]); } } } return map; }
Example 16
From project andlytics, under directory /src/com/github/andlyticsproject/cache/.
Source file: LRUBitmapCache.java

/** * Creates a new LRU cache. * @param cacheSize the maximum number of entries that will be kept in this cache. */ public LRUBitmapCache(int cacheSize){ this.cacheSize=cacheSize; int hashTableCapacity=(int)FloatMath.ceil(cacheSize / hashTableLoadFactor) + 1; map=new LinkedHashMap<String,Bitmap>(hashTableCapacity,hashTableLoadFactor,true){ private static final long serialVersionUID=1; @Override protected boolean removeEldestEntry( Map.Entry<String,Bitmap> eldest){ boolean result=size() > LRUBitmapCache.this.cacheSize; if (result) { if (eldest.getValue() != null) { Log.d(TAG,"Recycling bitmap: " + eldest.getKey() + " current cache size: "+ size()); } } return result; } } ; }
Example 17
From project Android, under directory /integration-tests/src/main/java/com/github/mobile/tests/gist/.
Source file: GistFilesViewActivityTest.java

@Override protected void setUp() throws Exception { super.setUp(); RoboGuice.injectMembers(getInstrumentation().getTargetContext().getApplicationContext(),this); gist=new Gist(); gist.setId("abcd"); Map<String,GistFile> files=new LinkedHashMap<String,GistFile>(); files.put("a",new GistFile().setFilename("a").setContent("aa")); files.put("b",new GistFile().setFilename("b").setContent("bb")); gist.setFiles(files); store.addGist(gist); setActivityIntent(GistFilesViewActivity.createIntent(gist,0)); }
Example 18
From project android-context, under directory /src/edu/fsu/cs/contextprovider/.
Source file: ContextExpandableListActivity.java

public void exportToFile() throws IOException { String path=Environment.getExternalStorageDirectory() + "/" + CSV_FILENAME; File file=new File(path); file.createNewFile(); if (!file.isFile()) { throw new IllegalArgumentException("Should not be a directory: " + file); } if (!file.canWrite()) { throw new IllegalArgumentException("File cannot be written: " + file); } Writer output=new BufferedWriter(new FileWriter(file)); HashMap<String,String> cntx=null; String line; cntx=ContextProvider.getAllUnordered(); for ( LinkedHashMap.Entry<String,String> entry : cntx.entrySet()) { ContextListItem item=new ContextListItem(); item.setName(entry.getKey()); item.setValue(entry.getValue()); line=item.toString(); output.write(line + "\n"); } output.close(); Toast.makeText(this,String.format("Saved",path),Toast.LENGTH_LONG).show(); Intent shareIntent=new Intent(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM,Uri.parse("file://" + path)); shareIntent.setType("text/plain"); startActivity(Intent.createChooser(shareIntent,"Share Context Using...")); }
Example 19
From project android-cropimage, under directory /src/com/android/camera/gallery/.
Source file: LruCache.java

@SuppressWarnings("serial") public LruCache(final int capacity){ mLruMap=new LinkedHashMap<K,V>(16,0.75f,true){ @Override protected boolean removeEldestEntry( Map.Entry<K,V> eldest){ return size() > capacity; } } ; }
Example 20
From project Android-MapForgeFragment, under directory /library-common/src/com/jakewharton/android/mapsforge_fragment/.
Source file: MapDatabaseIndexCache.java

private Map<IndexCacheEntryKey,byte[]> createMap(final int initialCapacity){ return new LinkedHashMap<IndexCacheEntryKey,byte[]>((int)(initialCapacity / LOAD_FACTOR) + 2,LOAD_FACTOR,true){ private static final long serialVersionUID=1L; @Override protected boolean removeEldestEntry( Map.Entry<IndexCacheEntryKey,byte[]> eldest){ return size() > initialCapacity; } } ; }
Example 21
From project android-vpn-settings, under directory /src/com/android/settings/vpn/.
Source file: VpnSettings.java

private void retrieveVpnListFromStorage(){ mVpnPreferenceMap=new LinkedHashMap<String,VpnPreference>(); mVpnProfileList=Collections.synchronizedList(new ArrayList<VpnProfile>()); mVpnListContainer.removeAll(); File root=new File(PROFILES_ROOT); String[] dirs=root.list(); if (dirs == null) return; for ( String dir : dirs) { File f=new File(new File(root,dir),PROFILE_OBJ_FILE); if (!f.exists()) continue; try { VpnProfile p=deserialize(f); if (p == null) continue; if (!checkIdConsistency(dir,p)) continue; mVpnProfileList.add(p); } catch ( IOException e) { Log.e(TAG,"retrieveVpnListFromStorage()",e); } } Collections.sort(mVpnProfileList,new Comparator<VpnProfile>(){ public int compare( VpnProfile p1, VpnProfile p2){ return p1.getName().compareTo(p2.getName()); } public boolean equals( VpnProfile p){ return false; } } ); for ( VpnProfile p : mVpnProfileList) { Preference pref=addPreferenceFor(p,false); } disableProfilePreferencesIfOneActive(); }
Example 22
From project AndroidLab, under directory /libs/unboundid/docs/examples/.
Source file: AuthRate.java

/** * {@inheritDoc} */ @Override() public LinkedHashMap<String[],String> getExampleUsages(){ final LinkedHashMap<String[],String> examples=new LinkedHashMap<String[],String>(1); final String[] args={"--hostname","server.example.com","--port","389","--bindDN","uid=admin,dc=example,dc=com","--bindPassword","password","--baseDN","dc=example,dc=com","--scope","sub","--filter","(uid=user.[1-1000000])","--credentials","password","--numThreads","10"}; final String description="Test authentication performance by searching randomly across a set " + "of one million users located below 'dc=example,dc=com' with ten " + "concurrent threads and performing simple binds with a password of "+ "'password'. The searches will be performed anonymously."; examples.put(args,description); return examples; }
Example 23
From project androidquery, under directory /demo/src/com/androidquery/test/async/.
Source file: AjaxLoadingActivity.java

public void async_xpp(){ String url="https://picasaweb.google.com/data/feed/base/featured?max-results=8"; aq.progress(R.id.progress).ajax(url,XmlPullParser.class,new AjaxCallback<XmlPullParser>(){ public void callback( String url, XmlPullParser xpp, AjaxStatus status){ Map<String,String> images=new LinkedHashMap<String,String>(); String currentTitle=null; try { int eventType=xpp.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG) { String tag=xpp.getName(); if ("title".equals(tag)) { currentTitle=xpp.nextText(); } else if ("content".equals(tag)) { String imageUrl=xpp.getAttributeValue(0); images.put(currentTitle,imageUrl); } } eventType=xpp.next(); } } catch ( Exception e) { AQUtility.report(e); } showResult(images,status); } } ); }
Example 24
From project android_8, under directory /src/com/google/gson/.
Source file: DefaultTypeAdapters.java

@SuppressWarnings({"rawtypes"}) private static ParameterizedTypeHandlerMap<InstanceCreator<?>> createDefaultInstanceCreators(){ ParameterizedTypeHandlerMap<InstanceCreator<?>> map=new ParameterizedTypeHandlerMap<InstanceCreator<?>>(); DefaultConstructorAllocator allocator=new DefaultConstructorAllocator(50); map.registerForTypeHierarchy(Map.class,new DefaultConstructorCreator<Map>(LinkedHashMap.class,allocator)); DefaultConstructorCreator<List> listCreator=new DefaultConstructorCreator<List>(ArrayList.class,allocator); DefaultConstructorCreator<Queue> queueCreator=new DefaultConstructorCreator<Queue>(LinkedList.class,allocator); DefaultConstructorCreator<Set> setCreator=new DefaultConstructorCreator<Set>(HashSet.class,allocator); DefaultConstructorCreator<SortedSet> sortedSetCreator=new DefaultConstructorCreator<SortedSet>(TreeSet.class,allocator); map.registerForTypeHierarchy(Collection.class,listCreator); map.registerForTypeHierarchy(Queue.class,queueCreator); map.registerForTypeHierarchy(Set.class,setCreator); map.registerForTypeHierarchy(SortedSet.class,sortedSetCreator); map.makeUnmodifiable(); return map; }
Example 25
From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/vpn/.
Source file: VpnSettings.java

private void retrieveVpnListFromStorage(){ mVpnPreferenceMap=new LinkedHashMap<String,VpnPreference>(); mVpnProfileList=Collections.synchronizedList(new ArrayList<VpnProfile>()); mVpnListContainer.removeAll(); File root=new File(PROFILES_ROOT); String[] dirs=root.list(); if (dirs == null) return; for ( String dir : dirs) { File f=new File(new File(root,dir),PROFILE_OBJ_FILE); if (!f.exists()) continue; try { VpnProfile p=deserialize(f); if (p == null) continue; if (!checkIdConsistency(dir,p)) continue; mVpnProfileList.add(p); } catch ( IOException e) { Log.e(TAG,"retrieveVpnListFromStorage()",e); } } Collections.sort(mVpnProfileList,new Comparator<VpnProfile>(){ public int compare( VpnProfile p1, VpnProfile p2){ return p1.getName().compareTo(p2.getName()); } public boolean equals( VpnProfile p){ return false; } } ); for ( VpnProfile p : mVpnProfileList) { Preference pref=addPreferenceFor(p,false); } disableProfilePreferencesIfOneActive(); }
Example 26
From project android_external_guava, under directory /src/com/google/common/collect/.
Source file: LinkedHashMultimap.java

private LinkedHashMultimap(int expectedKeys,int expectedValuesPerKey){ super(new LinkedHashMap<K,Collection<V>>(expectedKeys)); Preconditions.checkArgument(expectedValuesPerKey >= 0); this.expectedValuesPerKey=expectedValuesPerKey; linkedEntries=new LinkedHashSet<Map.Entry<K,V>>(expectedKeys * expectedValuesPerKey); }
Example 27
From project android_external_libphonenumber, under directory /java/src/com/android/i18n/phonenumbers/.
Source file: RegexCache.java

@SuppressWarnings("serial") public LRUCache(int size){ this.size=size; map=new LinkedHashMap<K,V>(size * 4 / 3 + 1,0.75f,true){ @Override protected boolean removeEldestEntry( Map.Entry<K,V> eldest){ return size() > LRUCache.this.size; } } ; }
Example 28
From project android_packages_apps_FileManager, under directory /src/org/openintents/filemanager/.
Source file: ThumbnailLoader.java

/** * Used for loading and decoding thumbnails from files. * @author PhilipHayes * @param context Current application context. */ public ThumbnailLoader(Context context){ mContext=context; purger=new Runnable(){ @Override public void run(){ Log.d(TAG,"Purge Timer hit; Clearing Caches."); clearCaches(); } } ; purgeHandler=new Handler(); mExecutor=Executors.newFixedThreadPool(POOL_SIZE); mBlacklist=new ArrayList<String>(); mSoftBitmapCache=new ConcurrentHashMap<String,SoftReference<Bitmap>>(MAX_CACHE_CAPACITY / 2); mHardBitmapCache=new LinkedHashMap<String,Bitmap>(MAX_CACHE_CAPACITY / 2,0.75f,true){ /** */ private static final long serialVersionUID=1347795807259717646L; @Override protected boolean removeEldestEntry( LinkedHashMap.Entry<String,Bitmap> eldest){ if (size() > MAX_CACHE_CAPACITY) { mSoftBitmapCache.put(eldest.getKey(),new SoftReference<Bitmap>(eldest.getValue())); return true; } else { return false; } } } ; }
Example 29
From project android_packages_apps_Gallery, under directory /src/com/android/camera/gallery/.
Source file: LruCache.java

@SuppressWarnings("serial") public LruCache(final int capacity){ mLruMap=new LinkedHashMap<K,V>(16,0.75f,true){ @Override protected boolean removeEldestEntry( Map.Entry<K,V> eldest){ return size() > capacity; } } ; }
Example 30
From project android_packages_apps_Gallery2, under directory /gallerycommon/src/com/android/gallery3d/common/.
Source file: LruCache.java

@SuppressWarnings("serial") public LruCache(final int capacity){ mLruMap=new LinkedHashMap<K,V>(16,0.75f,true){ @Override protected boolean removeEldestEntry( Map.Entry<K,V> eldest){ return size() > capacity; } } ; }
Example 31
From project android_packages_apps_phone, under directory /src/com/android/phone/sip/.
Source file: SipSettings.java

private void retrieveSipLists(){ mSipPreferenceMap=new LinkedHashMap<String,SipPreference>(); mSipProfileList=mProfileDb.retrieveSipProfileList(); processActiveProfilesFromSipService(); Collections.sort(mSipProfileList,new Comparator<SipProfile>(){ public int compare( SipProfile p1, SipProfile p2){ return getProfileName(p1).compareTo(getProfileName(p2)); } public boolean equals( SipProfile p){ return false; } } ); mSipListContainer.removeAll(); for ( SipProfile p : mSipProfileList) { addPreferenceFor(p); } if (!mSipSharedPreferences.isReceivingCallsEnabled()) return; for ( SipProfile p : mSipProfileList) { if (mUid == p.getCallingUid()) { try { mSipManager.setRegistrationListener(p.getUriString(),createRegistrationListener()); } catch ( SipException e) { Log.e(TAG,"cannot set registration listener",e); } } } }
Example 32
From project ANNIS, under directory /annis-gui/src/main/java/annis/gui/visualizers/component/grid/.
Source file: GridVisualizer.java

@Override public void attach(){ String resultID=input.getId(); grid=new AnnotationGrid(mediaController,resultID); grid.addStyleName("partitur_table"); addComponent(grid); SDocumentGraph graph=input.getDocument().getSDocumentGraph(); List<String> annos=new LinkedList<String>(getAnnotationLevelSet(graph,input.getNamespace())); String annosConfiguration=input.getMappings().getProperty(MAPPING_ANNOS_KEY); if (annosConfiguration != null && annosConfiguration.trim().length() > 0) { String[] split=annosConfiguration.split(","); annos.clear(); for ( String s : split) { annos.add(s.trim()); } } EList<SToken> token=graph.getSortedSTokenByText(); long startIndex=token.get(0).getSFeature(ANNIS_NS,FEAT_TOKENINDEX).getSValueSNUMERIC(); long endIndex=token.get(token.size() - 1).getSFeature(ANNIS_NS,FEAT_TOKENINDEX).getSValueSNUMERIC(); LinkedHashMap<String,ArrayList<Row>> rowsByAnnotation=parseSalt(input.getDocument().getSDocumentGraph(),annos,(int)startIndex,(int)endIndex); Row tokenRow=new Row(); for ( SToken t : token) { long idx=t.getSFeature(ANNIS_NS,FEAT_TOKENINDEX).getSValueSNUMERIC() - startIndex; String text=CommonHelper.getSpannedText(t); GridEvent event=new GridEvent(t.getSId(),(int)idx,(int)idx,text); SFeature featMatched=t.getSFeature(ANNIS_NS,FEAT_MATCHEDNODE); Long match=featMatched == null ? null : featMatched.getSValueSNUMERIC(); event.setMatch(match); tokenRow.addEvent(event); } ArrayList<Row> tokenRowList=new ArrayList<Row>(); tokenRowList.add(tokenRow); if (Boolean.parseBoolean(input.getMappings().getProperty(MAPPING_HIDE_TOK_KEY,"false")) == false) { rowsByAnnotation.put("tok",tokenRowList); } grid.setRowsByAnnotation(rowsByAnnotation); }
Example 33
public Map<String,String> definedProperties(){ Map<String,String> result=new LinkedHashMap<String,String>(); for ( String define : defineProperty.getValues()) { int pos=define.indexOf('='); if (pos == -1) { result.put(define,"true"); } else { result.put(define.substring(0,pos).trim(),define.substring(pos + 1).trim()); } } return result; }
Example 34
From project aranea, under directory /server/src/main/java/no/dusken/aranea/web/control/.
Source file: ContactPageController.java

@RequestMapping("/contact.do") public String getContactPageView(Model model){ Map<String,Person> persons=new LinkedHashMap<String,Person>(); for ( String roleAsStr : roles) { Role role=roleService.getRolesByName(roleAsStr); if (role != null && role.getPersons() != null && role.getPersons().size() > 0) { for ( Person p : role.getPersons()) { if (p.getActive()) { persons.put(roleAsStr,p); break; } } } } model.addAttribute("persons",persons); return contactPageViewLocation; }
Example 35
From project Arecibo, under directory /agent/src/main/java/com/ning/arecibo/agent/datasource/jmx/.
Source file: JMXClient.java

public Map<String,Object> getAttributeValues(MBeanDescriptor mbeanDesc,String[] attributeNames){ HashSet<String> expectedAttrNameSet=new HashSet<String>(attributeNames.length); HashSet<String> actualAttrNameSet=new HashSet<String>(attributeNames.length); for ( String attrName : attributeNames) { expectedAttrNameSet.add(attrName.toLowerCase()); } for ( String attrName : mbeanDesc.getAttributeNames()) { if (expectedAttrNameSet.contains(attrName.toLowerCase())) { actualAttrNameSet.add(attrName); } } Map<String,Object> result=new LinkedHashMap<String,Object>(); try { AttributeList attrList=mbeanConn.getAttributes(mbeanDesc.getObjectName(),actualAttrNameSet.toArray(new String[actualAttrNameSet.size()])); for ( Object attrObj : attrList) { Attribute attr=(Attribute)attrObj; result.put(attr.getName(),attr.getValue()); } } catch ( Exception ex) { throw new RuntimeException(ex); } return result; }
Example 36
From project arquillian-extension-drone, under directory /drone-configuration/src/main/java/org/jboss/arquillian/drone/configuration/.
Source file: SecurityActions.java

static Map<String,Field> getAccessableFields(final Class<?> source){ Map<String,Field> declaredAccessableFields=AccessController.doPrivileged(new PrivilegedAction<Map<String,Field>>(){ public Map<String,Field> run(){ Map<String,Field> foundFields=new LinkedHashMap<String,Field>(); for ( Field field : source.getDeclaredFields()) { if (Modifier.isFinal(field.getModifiers())) { continue; } if (!field.isAccessible()) { field.setAccessible(true); } foundFields.put(field.getName(),field); } return foundFields; } } ); return declaredAccessableFields; }
Example 37
From project arquillian-graphene, under directory /graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/configuration/.
Source file: SecurityActions.java

static Map<String,Field> getAccessableFields(final Class<?> source){ Map<String,Field> declaredAccessableFields=AccessController.doPrivileged(new PrivilegedAction<Map<String,Field>>(){ public Map<String,Field> run(){ Map<String,Field> foundFields=new LinkedHashMap<String,Field>(); for ( Field field : source.getDeclaredFields()) { if (Modifier.isFinal(field.getModifiers())) { continue; } if (!field.isAccessible()) { field.setAccessible(true); } foundFields.put(field.getName(),field); } return foundFields; } } ); return declaredAccessableFields; }
Example 38
From project asadmin, under directory /asadmin-java/src/test/java/org/n0pe/asadmin/.
Source file: ExternalProcessTest.java

public void testEnvVars(){ Map<String,String> env=new LinkedHashMap<String,String>(); env.put("JAVA_HOME","/home/paul/opt/jdk"); env.put("JAVA_HOME_WITH_SPACES","/home/paul/with spaces/opt/jdk"); String[] envStrings=AsAdmin.buildEnvironmentStrings(env); assertEquals("[JAVA_HOME=/home/paul/opt/jdk, JAVA_HOME_WITH_SPACES=\"/home/paul/with spaces/opt/jdk\"]",Arrays.toString(envStrings)); env.put("WRONG NAME","useless"); try { AsAdmin.buildEnvironmentStrings(env); fail("Environment variable with spaces in name are illegal"); } catch ( IllegalArgumentException ex) { } }
Example 39
From project asterisk-java, under directory /src/main/java/org/asteriskjava/manager/action/.
Source file: SipNotifyAction.java

/** * Sets an variable on the originated call. * @param name the name of the variable to set. * @param value the value of the variable to set. * @since 1.0.0 */ public void setVariable(String name,String value){ if (variables == null) { variables=new LinkedHashMap<String,String>(); } variables.put(name,value); }
Example 40
From project astyanax, under directory /src/main/java/com/netflix/astyanax/serializers/.
Source file: AbstractSerializer.java

public <V>Map<ByteBuffer,V> toBytesMap(Map<T,V> map){ Map<ByteBuffer,V> bytesMap=new LinkedHashMap<ByteBuffer,V>(computeInitialHashSize(map.size())); for ( Entry<T,V> entry : map.entrySet()) { bytesMap.put(toByteBuffer(entry.getKey()),entry.getValue()); } return bytesMap; }
Example 41
From project autopsy, under directory /Core/src/org/sleuthkit/autopsy/datamodel/.
Source file: AbstractFsContentNode.java

@Override protected Sheet createSheet(){ Sheet s=super.createSheet(); Sheet.Set ss=s.get(Sheet.PROPERTIES); if (ss == null) { ss=Sheet.createPropertiesSet(); s.put(ss); } Map<String,Object> map=new LinkedHashMap<String,Object>(); fillPropertyMap(map,content); FsContentPropertyType[] fsTypes=FsContentPropertyType.values(); final int FS_PROPS_LEN=fsTypes.length; final String NO_DESCR="no description"; for (int i=0; i < FS_PROPS_LEN; ++i) { final FsContentPropertyType propType=FsContentPropertyType.values()[i]; final String propString=propType.toString(); ss.put(new NodeProperty(propString,propString,NO_DESCR,map.get(propString))); } if (directoryBrowseMode) { ss.put(new NodeProperty(HIDE_PARENT,HIDE_PARENT,HIDE_PARENT,HIDE_PARENT)); } return s; }
Example 42
From project avro, under directory /lang/java/avro/src/main/java/org/apache/avro/reflect/.
Source file: ReflectData.java

private Collection<Field> getFields(Class recordClass){ Map<String,Field> fields=new LinkedHashMap<String,Field>(); Class c=recordClass; do { if (c.getPackage() != null && c.getPackage().getName().startsWith("java.")) break; for ( Field field : c.getDeclaredFields()) if ((field.getModifiers() & (Modifier.TRANSIENT | Modifier.STATIC)) == 0) if (fields.put(field.getName(),field) != null) throw new AvroTypeException(c + " contains two fields named: " + field); c=c.getSuperclass(); } while (c != null); return fields.values(); }
Example 43
From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.core/src/com/amazonaws/eclipse/explorer/sns/.
Source file: NewSubscriptionAction.java

@Override protected Control createCustomArea(Composite parent){ Composite composite=new Composite(parent,SWT.NONE); composite.setLayout(new GridLayout(2,false)); composite.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true)); new Label(composite,SWT.NONE).setText("Subscription Protocol:"); protocolCombo=new Combo(composite,SWT.DROP_DOWN | SWT.READ_ONLY); protocolCombo.setLayoutData(new GridData(SWT.FILL,SWT.TOP,true,false)); LinkedHashMap<String,String> protocolMap=new LinkedHashMap<String,String>(); protocolMap.put("Email (plain text)","email"); protocolMap.put("Email (JSON)","email-json"); protocolMap.put("SQS","sqs"); protocolMap.put("HTTP","http"); protocolMap.put("HTTPS","https"); protocolCombo.addSelectionListener(new SelectionListener(){ public void widgetSelected( SelectionEvent e){ updateControls(); } public void widgetDefaultSelected( SelectionEvent e){ } } ); for ( String label : protocolMap.keySet()) { protocolCombo.add(label); protocolCombo.setData(label,protocolMap.get(label)); } protocolCombo.select(0); endpointLabel=new Label(composite,SWT.NONE); endpointLabel.setText("Endpoint:"); endpointText=new Text(composite,SWT.BORDER); endpointText.setLayoutData(new GridData(SWT.FILL,SWT.TOP,true,false)); endpointText.addModifyListener(new ModifyListener(){ public void modifyText( ModifyEvent e){ updateControls(); } } ); updateControls(); return composite; }
Example 44
From project azkaban, under directory /azkaban/src/java/azkaban/flow/.
Source file: CachingFlowManager.java

public CachingFlowManager(FlowManager baseManager,final int cacheSize){ this.baseManager=baseManager; this.flowCache=Collections.synchronizedMap(new LinkedHashMap<String,FlowExecutionHolder>((int)(cacheSize * 1.5),0.75f,true){ @Override protected boolean removeEldestEntry( Map.Entry<String,FlowExecutionHolder> eldest){ final boolean tooManyElements=super.size() > cacheSize; if (tooManyElements) { final Status status=eldest.getValue().getFlow().getStatus(); if (status != Status.RUNNING) { return true; } else { log.warn(String.format("Cache is at size[%s] and should have evicted an entry, but the oldest entry wasn't completed[%s]. Perhaps the cache size is too small",super.size(),status)); } } return false; } } ); }
Example 45
/** * Note: more expensive than getScoredCandidates(). * @return a map sorted by scores in descending order. */ public LinkedHashMap<EquivalenceClass,Double> getOrderedScoredCandidates(){ LinkedHashMap<EquivalenceClass,Double> map=new LinkedHashMap<EquivalenceClass,Double>(); for ( ScoredCandidateSet candSet : m_scoredCandSets) { for ( EquivalenceClass eq : candSet.m_candidates) { map.put(eq,candSet.m_score); } } return map; }
Example 46
From project ballroom, under directory /widgets/src/main/java/org/jboss/ballroom/client/widgets/forms/.
Source file: Form.java

public void setFieldsInGroup(String group,FormItem... items){ LinkedHashMap<String,FormItem> groupItems=new LinkedHashMap<String,FormItem>(); formItems.put(group,groupItems); for ( FormItem item : items) { String title=item.getTitle(); if (title.length() > maxTitleLength) { maxTitleLength=title.length(); } String itemKey=item.getName(); if (groupItems.containsKey(itemKey)) { groupItems.put(itemKey + "#" + nextId,item); nextId++; } else { groupItems.put(itemKey,item); } } }
Example 47
From project Baseform-Epanet-Java-Library, under directory /src/org/addition/epanet/network/.
Source file: FieldsMap.java

/** * Init fields default configuration */ public FieldsMap(){ try { fields=new LinkedHashMap<Type,Field>(); units=new LinkedHashMap<Type,Double>(); for ( Type type : Type.values()) setField(type,new Field(type.parseStr)); getField(Type.FRICTION).setPrecision(3); for (int i=Type.DEMAND.id; i <= Type.QUALITY.id; i++) getField(Type.values()[i]).setEnabled(true); for (int i=Type.FLOW.id; i <= Type.HEADLOSS.id; i++) getField(Type.values()[i]).setEnabled(true); } catch ( ENException e) { e.printStackTrace(); } }
Example 48
public static void processError(BuzzContext ctx,int statusCode,String statusMessage,String message,String details,String moreInfo) throws IOException { Map<String,Object> object=new LinkedHashMap<String,Object>(); object.put("status",statusCode); object.put("statusMessage",statusMessage); object.put("message",message); object.put("details",details); object.put("moreInfo",moreInfo); ctx.res.setStatus(statusCode); ctx.res.setContentType("text/plain"); ctx.res.getOutputStream().print(ToStringUtil.toString(object)); ctx.r.setHandled(true); }
Example 49
From project BibleQuote-for-Android, under directory /src/com/BibleQuote/activity/.
Source file: SearchActivity.java

@Override protected Boolean doInBackground(String... params){ if (query.equals("")) { return true; } int posFrom=s1.getSelectedItemPosition(); int posTo=s2.getSelectedItemPosition(); if (posFrom == AdapterView.INVALID_POSITION || posTo == AdapterView.INVALID_POSITION) { return true; } String fromBookID=((ItemList)s1.getItemAtPosition(posFrom)).get("ID"); String toBookID=((ItemList)s2.getItemAtPosition(posTo)).get("ID"); searchResults=new LinkedHashMap<String,String>(); try { searchResults=myLibararian.search(query,fromBookID,toBookID); } catch ( BookNotFoundException e) { Log.e(TAG,e.getMessage()); } catch ( OpenModuleException e) { Log.e(TAG,e.getMessage()); } return true; }
Example 50
@Override public Flash add(String name,String flashMessage){ Assert.notNull(name,"Flash attribute name must not be null"); flashMessage=PlaceHolderUtils.resolve(flashMessage,invocation); if (next.size() == 0) { next=new LinkedHashMap<String,String>(2); } next.put(name,flashMessage); if (logger.isDebugEnabled()) { logger.debug("add flashMessage: " + name + "="+ flashMessage); } return this; }
Example 51
From project blueprint-namespaces, under directory /blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/.
Source file: BlueprintRepository.java

private Map<String,Object> createInstances(Collection<String> names){ DependencyGraph graph=new DependencyGraph(this); HashMap<String,Object> objects=new LinkedHashMap<String,Object>(); for ( Map.Entry<String,Recipe> entry : graph.getSortedRecipes(names).entrySet()) { objects.put(entry.getKey(),entry.getValue().create()); } return objects; }
Example 52
From project bndtools, under directory /bndtools.release/src/bndtools/release/.
Source file: ReleaseAction.java

/** * @see IActionDelegate#selectionChanged(IAction,ISelection) */ public void selectionChanged(IAction action,ISelection selection){ IFile[] locations=getLocations(selection); bndFiles=new LinkedHashMap<Project,List<File>>(); for ( IFile iFile : locations) { File file=iFile.getLocation().toFile(); Project project; try { project=Workspace.getProject(file.getParentFile()); } catch ( Exception e) { throw new RuntimeException(e); } List<File> projectFiles=bndFiles.get(project); if (projectFiles == null) { projectFiles=new ArrayList<File>(); bndFiles.put(project,projectFiles); } projectFiles.add(file); } }
Example 53
From project bonecp, under directory /bonecp/src/test/java/com/jolbox/bonecp/.
Source file: TestPoolUtil.java

/** * Tests formatting stuff (exceptions case) * @throws SQLException */ @Test public void testPoolUtilExceptions() throws SQLException { Map<Object,Object> logParams=new LinkedHashMap<Object,Object>(); logParams.put("1","123"); logParams.put("2",null); Blob mockBlob=createNiceMock(Blob.class); expect(mockBlob.length()).andThrow(new SQLException()); replay(mockBlob); logParams.put("3",mockBlob); Clob mockClob=createNiceMock(Clob.class); expect(mockClob.length()).andThrow(new SQLException()); replay(mockClob); logParams.put("4",mockClob); Array mockArray=createNiceMock(java.sql.Array.class); expect(mockArray.getBaseTypeName()).andThrow(new SQLException()); replay(mockArray); logParams.put("5",mockArray); Ref mockSerialRef=createNiceMock(Ref.class); expect(mockSerialRef.getBaseTypeName()).andThrow(new SQLException()); replay(mockSerialRef); logParams.put("6",mockSerialRef); assertEquals("ID='123' AND FOO='?' and LALA=\"BOO\" NULL (blob of unknown length) (cblob of unknown length) (array of unknown type) (ref of unknown type) ?",PoolUtil.fillLogParams("ID=? AND FOO='?' and LALA=\"BOO\" ? ? ? ? ? ?",logParams)); }
Example 54
From project Book-Catalogue, under directory /src/com/eleybourn/bookcatalogue/.
Source file: CropLruCache.java

public CropLruCache(final int capacity){ mLruMap=new LinkedHashMap<K,V>(16,0.75f,true){ @Override protected boolean removeEldestEntry( Map.Entry<K,V> eldest){ return size() > capacity; } } ; }
Example 55
From project bpelunit, under directory /net.bpelunit.framework/src/main/java/net/bpelunit/framework/model/test/.
Source file: TestSuite.java

public TestSuite(String suiteName,URL suiteBaseURL,ProcessUnderTest suiteProcessUnderTest){ fStatus=ArtefactStatus.createInitialStatus(); fResultListeners=new ArrayList<ITestResultListener>(); fLogger=Logger.getLogger(getClass()); fName=suiteName; fProcessUnderTest=suiteProcessUnderTest; fCurrentlyRunning=false; fTestCaseMap=new LinkedHashMap<String,TestCase>(); setBaseURL(suiteBaseURL); }
Example 56
From project bson4jackson, under directory /src/main/java/de/undercouch/bson4jackson/.
Source file: BsonParser.java

/** * Reads a DBPointer from the stream * @return the json token read * @throws IOException if an I/O error occurs */ protected JsonToken handleDBPointer() throws IOException { Map<String,Object> pointer=new LinkedHashMap<String,Object>(); pointer.put("$ns",readString()); pointer.put("$id",readObjectId()); getContext().value=pointer; return JsonToken.VALUE_EMBEDDED_OBJECT; }
Example 57
From project camel-osgi, under directory /component/src/test/java/org/apache/camel/osgi/service/filter/.
Source file: FiltersTest.java

@Test public void testAllEq() throws Exception { Map<String,String> attrs=new LinkedHashMap<String,String>(); attrs.put("a","b"); attrs.put("c","d"); Criterion criterion=allEq(attrs); assertThat(criterion.value(),equalTo("(&(a=b)(c=d))")); assertThat(criterion.filter(),notNullValue()); }
Example 58
From project Carolina-Digital-Repository, under directory /access/src/main/java/edu/unc/lib/dl/ui/util/.
Source file: LookupMappingsSettings.java

public static void updateMappings(){ for ( String sourcePath : sourcePaths) { try { Document document=XMLRetrievalService.getXMLDocument(sourcePath); XPath xpath=XPath.newInstance("/mappings/mapping"); @SuppressWarnings("unchecked") List<Element> nodes=xpath.selectNodes(document); for ( Element node : nodes) { Map<String,String> mapping; Attribute mappingKey=node.getAttribute("key"); if (mappingKey == null) continue; Attribute ordered=node.getAttribute("ordered"); if (ordered == null || !Boolean.parseBoolean(ordered.getValue())) { mapping=new HashMap<String,String>(); } else { mapping=new LinkedHashMap<String,String>(); } mappings.put(mappingKey.getValue(),mapping); xpath=XPath.newInstance("pair"); @SuppressWarnings("unchecked") List<Element> pairNodes=xpath.selectNodes(node); for ( Element pairNode : pairNodes) { Attribute key=pairNode.getAttribute("key"); if (key != null) { mapping.put(key.getValue(),pairNode.getValue()); } } } } catch ( Exception e) { } } }
Example 59
From project cas, under directory /cas-server-core/src/main/java/org/jasig/cas/monitor/.
Source file: HealthCheckMonitor.java

/** * {@inheritDoc} */ public HealthStatus observe(){ final Map<String,Status> results=new LinkedHashMap<String,Status>(this.monitors.size()); StatusCode code=StatusCode.UNKNOWN; Status result; for ( final Monitor monitor : this.monitors) { result=monitor.observe(); if (result.getCode().value() > code.value()) { code=result.getCode(); } results.put(monitor.getName(),result); } return new HealthStatus(code,results); }
Example 60
private void initializeNewJobsMap(){ jobsMap=new LinkedHashMap<String,Callable<Throwable>>(); TopologicalOrderIterator<Flow,Integer> topoIterator=flowGraph.getTopologicalIterator(); while (topoIterator.hasNext()) { Flow flow=topoIterator.next(); cascadeStats.addFlowStats(flow.getFlowStats()); CascadeJob job=new CascadeJob(flow); jobsMap.put(flow.getName(),job); List<CascadeJob> predecessors=new ArrayList<CascadeJob>(); for ( Flow predecessor : Graphs.predecessorListOf(flowGraph,flow)) predecessors.add((CascadeJob)jobsMap.get(predecessor.getName())); job.init(predecessors); } }
Example 61
From project cascading-avro, under directory /cascading-avro/src/main/java/com/maxpoint/cascading/avro/.
Source file: AvroScheme.java

public AvroScheme(Schema dataSchema){ this.dataSchema=dataSchema; final LinkedHashMap<String,FieldType> schemaFields=parseSchema(dataSchema,ALLOWED_TYPES); final Fields fields=fields(schemaFields); setSinkFields(fields); setSourceFields(fields); final Collection<FieldType> types=schemaFields.values(); fieldTypes=types.toArray(new FieldType[types.size()]); }
Example 62
public static void main(String[] args){ Map<String,String> options=new LinkedHashMap<String,String>(); List<String[]> params=new LinkedList<String[]>(); for ( String arg : args) { int index=arg.indexOf("="); if (arg.startsWith("-")) { if (index != -1) options.put(arg.substring(0,index),arg.substring(index + 1)); else options.put(arg,null); } else { if (index != -1) params.add(new String[]{arg.substring(0,index),arg.substring(index + 1)}); else params.add(new String[]{arg,null}); } } try { new Main(options,params).execute(); } catch ( IllegalArgumentException exception) { System.out.println(exception.getMessage()); printUsage(); } }
Example 63
From project cb2java, under directory /src/main/java/net/sf/cb2java/data/.
Source file: GroupData.java

/** * Convert the copybook group into a Java Map or List. Single items (occurs == 1) are placed as entries in a <code>Map</code>. The Keys of a map are listed in the same order as the Copybook definition. Multiple-occurs items are placed inside an immutable <code>List</code>. * @author github.com/devstopfix/cb2java * @return the copybook data as a map */ @Override protected Object toPOJO(){ Map<String,Object> group=new LinkedHashMap<String,Object>(this.wrapper.size()); Iterator<Data> groupIterator=wrapper.iterator(); while (groupIterator.hasNext()) { Data child=groupIterator.next(); int occurs=child.getDefinition().getOccurs(); if (occurs > 1) { List childOccurs=new ArrayList(occurs); childOccurs.add(child.toPOJO()); for (int i=1; i < occurs; i++) { childOccurs.add(groupIterator.next().toPOJO()); } group.put(child.getName(),Collections.unmodifiableList(childOccurs)); } else { group.put(child.getName(),child.toPOJO()); } } return group; }
Example 64
From project cdk, under directory /maven-resources-plugin/src/main/java/org/richfaces/cdk/vfs/zip/.
Source file: ZipNode.java

public ZipNode getOrCreateChild(String name){ setDirectory(true); if (children == null) { children=new LinkedHashMap<String,ZipNode>(); } String lcName=name.toLowerCase(); ZipNode node=children.get(lcName); if (node == null) { node=new ZipNode(name); children.put(lcName,node); } return node; }
Example 65
From project ceylon-runtime, under directory /testsuite/src/test/java/org/jboss/ceylon/test/modules/.
Source file: ModulesTest.java

protected void testArchive(Archive module,String run,Archive... libs) throws Throwable { File tmpdir=AccessController.doPrivileged(new PrivilegedAction<File>(){ public File run(){ return new File(System.getProperty("ceylon.repo",System.getProperty("java.io.tmpdir"))); } } ); List<File> files=new ArrayList<File>(); try { files.add(createModuleFile(tmpdir,module)); for ( Archive lib : libs) files.add(createModuleFile(tmpdir,lib)); String name; String version; String fullName=module.getName(); final boolean isDefault=(Constants.DEFAULT + ".car").equals(fullName); if (isDefault) { name=Constants.DEFAULT.toString(); version=null; } else { int p=fullName.indexOf("-"); if (p < 0) throw new IllegalArgumentException("No name and version split: " + fullName); name=fullName.substring(0,p); version=fullName.substring(p + 1,fullName.lastIndexOf(".")); } Map<String,String> args=new LinkedHashMap<String,String>(); args.put(Constants.CEYLON_ARGUMENT_PREFIX + Argument.REPOSITORY.toString(),tmpdir.toString()); if (run != null) args.put(Constants.CEYLON_ARGUMENT_PREFIX + Argument.RUN.toString(),run); execute(name + "/" + version,args); } finally { for ( File file : files) delete(file); } }
Example 66
From project chatbots-library, under directory /distribution/src/codeanticode/chatbots/alice/parser/.
Source file: SubstitutionBuilder.java

public void clear(){ substitutions.clear(); substitutions.put("correction",new LinkedHashMap<String,String>()); substitutions.put("protection",new LinkedHashMap<String,String>()); substitutions.put("accentuation",new LinkedHashMap<String,String>()); substitutions.put("punctuation",new LinkedHashMap<String,String>()); substitutions.put("person",new LinkedHashMap<String,String>()); substitutions.put("person2",new LinkedHashMap<String,String>()); substitutions.put("gender",new LinkedHashMap<String,String>()); }
Example 67
From project ChkBugReport, under directory /src/com/sonyericsson/chkbugreport/traceview/.
Source file: TreePNGPlugin.java

private boolean addToQueue(Module rep,int tid,Vector<MethodRun> queue,LinkedHashMap<Integer,Chart> charts,MethodRun run){ if (run.endLocalTime - run.startLocalTime < MIN_RUN_TIME) { return false; } Chart chart=charts.get(run.mid); if (chart == null) { if (charts.size() >= TRACE_COUNT) { return false; } chart=new Chart(); chart.mid=run.mid; chart.fn=String.format("trace_%d_%d.png",tid,run.mid); createEmptyChart(chart); charts.put(run.mid,chart); } queue.add(run); return true; }