本文整理汇总了Java中org.apache.commons.collections.BidiMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java BidiMap.put方法的具体用法?Java BidiMap.put怎么用?Java BidiMap.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.collections.BidiMap
的用法示例。
在下文中一共展示了BidiMap.put方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseSpringSchemas
import org.apache.commons.collections.BidiMap; //导入方法依赖的package包/类
private Map<String, String> parseSpringSchemas(String springSchemasContent) {
BidiMap schemaUrlsAndFileNames = new TreeBidiMap();
for (String line : springSchemasContent.split("\n")) {
if (line != null && !line.startsWith("#") && line.contains("=")) {
String url = line.substring(0, line.indexOf("=")).replaceAll("\\\\", "");
String fileName = line.substring(line.indexOf("=") + 1);
if (schemaUrlsAndFileNames.containsValue(fileName)) {
if (url.contains("current")) { //Avoid duplicates and prefer URL with "current"
schemaUrlsAndFileNames.removeValue(fileName);
schemaUrlsAndFileNames.put(url, fileName);
}
} else {
schemaUrlsAndFileNames.put(url, fileName);
}
}
}
return schemaUrlsAndFileNames;
}
示例2: buildBidirecionalMapFromParameters
import org.apache.commons.collections.BidiMap; //导入方法依赖的package包/类
/**
* parse the given lookup parameter string into a bidirectinal map
*
* @param lookupParameters the lookup parameter string
* @param accountingLinePrefix the actual accounting line prefix
* @return a bidirectinal map that holds all the given lookup parameters
*/
private BidiMap buildBidirecionalMapFromParameters(String parameters, String accountingLinePrefix) {
BidiMap parameterMap = new DualHashBidiMap();
// if we didnt get any incoming parameters, then just return an empty parameterMap
if (StringUtils.isBlank(parameters)) {
return parameterMap;
}
String[] parameterArray = StringUtils.split(parameters, OLEConstants.FIELD_CONVERSIONS_SEPERATOR);
for (String parameter : parameterArray) {
String[] entrySet = StringUtils.split(parameter, OLEConstants.FIELD_CONVERSION_PAIR_SEPERATOR);
if (entrySet != null) {
String parameterKey = escapeAccountingLineName(entrySet[0], accountingLinePrefix);
String parameterValue = escapeAccountingLineName(entrySet[1], accountingLinePrefix);
parameterMap.put(parameterKey, parameterValue);
}
}
return parameterMap;
}
示例3: imageArchiveConfig
import org.apache.commons.collections.BidiMap; //导入方法依赖的package包/类
@Autowired
@Bean
public Config imageArchiveConfig(Environment environment) {
BidiMap languages = new DualHashBidiMap();
languages.put("eng", "en");
languages.put("swe", "sv");
Config config = new Config();
config.setStoragePath(new File(environment.getProperty("ImageArchiveStoragePath")));
config.setTmpPath(new File(environment.getProperty("ImageArchiveTempPath")));
config.setImageMagickPath(new File(environment.getProperty("ImageMagickPath")));
config.setImagesPath(new File(environment.getProperty("ImageArchiveImagesPath")));
config.setLibrariesPath(new File(environment.getProperty("ImageArchiveLibrariesPath")));
config.setOldLibraryPaths(new File[]{new File(environment.getProperty("ImageArchiveOldLibraryPaths"))});
config.setUsersLibraryFolder(environment.getProperty("ImageArchiveUsersLibraryFolder"));
config.setMaxImageUploadSize(Long.parseLong(environment.getProperty("ImageArchiveMaxImageUploadSize")));
config.setMaxZipUploadSize(Long.parseLong(environment.getProperty("ImageArchiveMaxZipUploadSize")));
config.setLanguages(languages);
return config;
}
示例4: buildBidirecionalMapFromParameters
import org.apache.commons.collections.BidiMap; //导入方法依赖的package包/类
/**
* parse the given lookup parameter string into a bidirectinal map
*
* @param lookupParameters the lookup parameter string
* @param accountingLinePrefix the actual accounting line prefix
* @return a bidirectinal map that holds all the given lookup parameters
*/
private BidiMap buildBidirecionalMapFromParameters(String parameters, String accountingLinePrefix) {
BidiMap parameterMap = new DualHashBidiMap();
// if we didnt get any incoming parameters, then just return an empty parameterMap
if (StringUtils.isBlank(parameters)) {
return parameterMap;
}
String[] parameterArray = StringUtils.split(parameters, KFSConstants.FIELD_CONVERSIONS_SEPERATOR);
for (String parameter : parameterArray) {
String[] entrySet = StringUtils.split(parameter, KFSConstants.FIELD_CONVERSION_PAIR_SEPERATOR);
if (entrySet != null) {
String parameterKey = escapeAccountingLineName(entrySet[0], accountingLinePrefix);
String parameterValue = escapeAccountingLineName(entrySet[1], accountingLinePrefix);
parameterMap.put(parameterKey, parameterValue);
}
}
return parameterMap;
}
示例5: flip_map_entries_with_apachecommons
import org.apache.commons.collections.BidiMap; //导入方法依赖的package包/类
@Test
public void flip_map_entries_with_apachecommons() {
BidiMap stateCodeToDescription = new DualHashBidiMap();
stateCodeToDescription.put("WI", "Wisconsin");
stateCodeToDescription.put("MN", "Minnesota");
stateCodeToDescription.put("FL", "Florida");
stateCodeToDescription.put("IA", "Iowa");
stateCodeToDescription.put("OH", "Ohio");
BidiMap descriptionToStateCode = stateCodeToDescription
.inverseBidiMap();
logger.info(descriptionToStateCode);
assertEquals("IA", descriptionToStateCode.get("Iowa"));
}
示例6: assignColumnNames
import org.apache.commons.collections.BidiMap; //导入方法依赖的package包/类
protected void assignColumnNames()
{
BidiMap indexColumns = new DualHashBidiMap();
for (int i = 0; i < crtRecordColumnValues.size(); i++)
{
String name = crtRecordColumnValues.get(i);
Integer existingIdx = (Integer) indexColumns.getKey(name);
if (existingIdx == null)
{
//use the name from the file if possible
indexColumns.put(i, name);
}
else
{
//the name is taken, force COLUMN_i for this column and recursively if COLUMN_x is already used
Integer forceIndex = i;
do
{
String indexName = INDEXED_COLUMN_PREFIX + forceIndex;
Integer existingIndex = (Integer) indexColumns.getKey(indexName);
indexColumns.put(forceIndex, indexName);
forceIndex = existingIndex;
}
while(forceIndex != null);
}
}
this.columnNames = new LinkedHashMap<String, Integer>();
for (int i = 0; i < crtRecordColumnValues.size(); i++)
{
String columnName = (String) indexColumns.get(i);
this.columnNames.put(columnName, i);
}
}
示例7: extractAnnotationSpans
import org.apache.commons.collections.BidiMap; //导入方法依赖的package包/类
public static AnnotationSpans extractAnnotationSpans(JCas jCas)
{
BidiMap sentenceBeginIndexToCharacterIndex = new TreeBidiMap();
BidiMap sentenceEndIndexToCharacterIndex = new TreeBidiMap();
List<Sentence> sentences = new ArrayList<>(JCasUtil.select(jCas, Sentence.class));
for (int i = 0; i < sentences.size(); i++) {
Sentence sentence = sentences.get(i);
sentenceBeginIndexToCharacterIndex.put(i, sentence.getBegin());
sentenceEndIndexToCharacterIndex.put(i, sentence.getEnd());
}
// System.out.println(sentenceBeginIndexToCharacterIndex);
// System.out.println(sentenceEndIndexToCharacterIndex);
AnnotationSpans annotationSpans = new AnnotationSpans(
sentenceBeginIndexToCharacterIndex.size());
Collection<ArgumentComponent> components = JCasUtil.select(jCas, ArgumentComponent.class);
for (ArgumentComponent component : components) {
if (!ArgumentUnitUtils.isImplicit(component)) {
// System.out.println("=====");
// System.out.println(component.getCoveredText());
int relativeOffset = (int) sentenceBeginIndexToCharacterIndex
.getKey(component.getBegin());
int endingSentenceIndex = (int) sentenceEndIndexToCharacterIndex
.getKey(component.getEnd());
int length = endingSentenceIndex - relativeOffset + 1;
String type = component.getType().getShortName();
SingleAnnotationSpan singleAnnotationSpan = new SingleAnnotationSpan(type,
relativeOffset, length);
annotationSpans.getAnnotationSpans().add(singleAnnotationSpan);
}
}
return annotationSpans;
}
示例8: fold
import org.apache.commons.collections.BidiMap; //导入方法依赖的package包/类
/**
* Creates a <code>Graph</code> which is a "folded" version of <code>h</code>.
*
* <p>If <code>use_vertices</code> is true, the vertices of the new graph
* correspond to the vertices of <code>h</code>, and <code>a</code>
* is connected to <code>b</code> in the new graph if the corresponding vertices
* in <code>h</code> are connected by a hyperedge. Thus, each hyperedge with
* <i>k</i> vertices in <code>h</code> would induce a <i>k</i>-clique in the new graph.</p>
*
* <p>If <code>use_vertices</code> is false, then the vertices of the new
* graph correspond to the hyperedges of <code>h</code>, and <code>a</code>
* is connected to <code>b</code> in the new graph if the corresponding hyperedges
* in <code>h</code> share a vertex. Thus, each vertex connected to <i>k</i>
* hyperedges in <code>h</code> would induce a <i>k</i>-clique in the new graph.</p>
*
* <p>If <code>nev</code> is null,
* adds the connecting element as a decoration on the corresponding edge in the new
* graph; otherwise, sets the weight of each edge to the number of parallel
* paths between the corresponding vertices in the original graph that are
* encountered in the folding process.</p>
*/
public Graph fold(Hypergraph h, Graph target, boolean use_vertices, NumberEdgeValue nev, BidiMap map)
{
undirected = true;
if (target == null)
target = createGraph();
VertexGenerator vg = GraphUtils.getVertexGenerator(target);
if (vg == null)
vg = new TypedVertexGenerator(target);
Map m = new HashMap();
Set vertices;
Set edges;
// vertices and hyperedges are duals of one another; we can treat
// them equivalently for this purpose
if (use_vertices)
{
vertices = h.getVertices();
edges = h.getEdges();
}
else
{
vertices = h.getEdges();
edges = h.getVertices();
}
// create vertices:
// for each "vertex", create a new vertex and import user data
for (Iterator iter = vertices.iterator(); iter.hasNext(); )
{
Element av = (Element)iter.next();
Vertex v = vg.create();
v.importUserData(av);
target.addVertex(v);
m.put(av, v);
map.put(v, av);
}
// create edges:
// for each "hyperedge", create an edge between each incident vertex pair
for (Iterator iter = edges.iterator(); iter.hasNext(); )
{
Element he = (Element)iter.next();
Set elts = he.getIncidentElements();
Vertex[] v_array = new Vertex[elts.size()];
int i = 0;
for (Iterator e_iter = elts.iterator(); e_iter.hasNext(); )
v_array[i++] = (Vertex)(m.get(e_iter.next()));
for (i = 0; i < v_array.length; i++)
for (int j = i + 1; j < v_array.length; j++)
addEdge(target, v_array[i], he, v_array[j], nev);
}
return target;
}