本文整理汇总了Java中org.apache.commons.collections.BidiMap类的典型用法代码示例。如果您正苦于以下问题:Java BidiMap类的具体用法?Java BidiMap怎么用?Java BidiMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BidiMap类属于org.apache.commons.collections包,在下文中一共展示了BidiMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getKeyListByValueList
import org.apache.commons.collections.BidiMap; //导入依赖的package包/类
/**
* 根据值反向获取key
* @param <R>
* @param <T>
* @param source
* @param valueList Map的值集合
* @return Map的key集合
*/
public static <R,T> List<R> getKeyListByValueList(BidiMap source,List<T> valueList){
if(null == source || null == valueList){
return new ArrayList<R>();
}
List<R> result = new ArrayList<R>();
for(T value : valueList){
R key = (R) source.getKey(value);
if(null == key){
continue;
}
result.add(key);
}
return result;
}
示例8: createNameColumnConfig
import org.apache.commons.collections.BidiMap; //导入依赖的package包/类
private static NameColumnConfig createNameColumnConfig(final Set<String> columnMappingNames, final BidiMap bidirectionalColumnMappings) {
if (columnMappingNames.contains(ColumnMappingOption.FULLNAME)) {
Integer columnIndex = (Integer)bidirectionalColumnMappings.getKey(ColumnMappingOption.FULLNAME);
return NameColumnConfig.createForOneColumn(columnIndex);
}
else {
Integer firstNameColumnIndex = (Integer)bidirectionalColumnMappings.getKey(ColumnMappingOption.FIRSTNAME);
Integer lastNameColumnIndex = (Integer)bidirectionalColumnMappings.getKey(ColumnMappingOption.LASTNAME);
return NameColumnConfig.createForTwoColumns(firstNameColumnIndex, lastNameColumnIndex);
}
}
示例9: getDateFormatToRegExps
import org.apache.commons.collections.BidiMap; //导入依赖的package包/类
public static BidiMap getDateFormatToRegExps( String locale ) {
if ( locale == null || LOCALE_en_US.equalsIgnoreCase( locale ) ) {
return DATE_FORMAT_TO_REGEXPS_US;
} else {
return DATE_FORMAT_TO_REGEXPS;
}
}
示例10: testPatternsFrom
import org.apache.commons.collections.BidiMap; //导入依赖的package包/类
private void testPatternsFrom( BidiMap formatToRegExps, String locale ) {
Iterator iterator = formatToRegExps.keySet().iterator();
while ( iterator.hasNext() ) {
String pattern = (String) iterator.next();
String dateString = buildTestDate( pattern );
assertEquals( "Did not detect a matching date pattern using the date \"" + dateString + "\"", pattern,
DateDetector.detectDateFormatBiased( dateString, locale, pattern ) );
}
}
示例11: 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;
}
示例12: getLanguages
import org.apache.commons.collections.BidiMap; //导入依赖的package包/类
public BidiMap getLanguages() {
return languages;
}
示例13: setLanguages
import org.apache.commons.collections.BidiMap; //导入依赖的package包/类
public void setLanguages(BidiMap languages) {
this.languages = languages;
}
示例14: printReport
import org.apache.commons.collections.BidiMap; //导入依赖的package包/类
/**
* Display results to the user.
* @param result
*/
protected void printReport(BidiMap result) {
final String Dash6 = "------";
final String Dash10 = "----------";
final String Dash60 = "------------------------------------------------------------";
Formatter f = new Formatter();
// Print header.
String format = "%-5.5s|%-10.10s|%-60.60s\n";
Object[] hSep = new Object[] { Dash6, Dash10, Dash60 };
f.format(format, hSep);
f.format(format, new Object[] { "Score", "Code", "Term" });
f.format(format, hSep);
// Iterate over the result.
for (MapIterator items = result.inverseBidiMap().mapIterator(); items.hasNext(); ) {
ScoredTerm st = (ScoredTerm) items.next();
String code = (String) items.getValue();
// Evaluate code
if (code != null && code.length() > 10)
code = code.substring(0, 7) + "...";
// Evaluate term (wrap if necessary)
String term = st.term;
if (term != null && term.length() < 60)
f.format(format, new Object[] {st.score, code, term });
else {
String sub = term.substring(0, 60);
f.format(format, new Object[] {st.score, code, sub });
int begin = 60; int end = term.length();
while (begin < end) {
sub = term.substring(begin, Math.min(begin+60, end));
f.format(format, new Object[] {"", "", sub });
begin+=60;
}
}
}
Util.displayMessage(f.out().toString());
}
示例15: 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;
}