当前位置: 首页>>代码示例>>Java>>正文


Java KeyValue类代码示例

本文整理汇总了Java中org.apache.commons.collections.KeyValue的典型用法代码示例。如果您正苦于以下问题:Java KeyValue类的具体用法?Java KeyValue怎么用?Java KeyValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


KeyValue类属于org.apache.commons.collections包,在下文中一共展示了KeyValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertAndOrderField

import org.apache.commons.collections.KeyValue; //导入依赖的package包/类
private List<KeyValue> convertAndOrderField(HashMap<String, Integer> tmpField, Integer threshold) {

        List<Entry<String, Integer>> list = new ArrayList<>(tmpField.entrySet());
        Collections.sort(list, new Comparator<Entry<String, Integer>>() {
            @Override
            public int compare(Entry<String, Integer> o1, Entry<String, Integer> o2) {
                return o2.getValue().compareTo(o1.getValue()); //Note: exchanged o2 and o1 for descending order!
            }
        });

        List<KeyValue> result = new ArrayList<>();
        int i = 0;
        for (Iterator<Entry<String, Integer>> it = list.iterator(); it.hasNext(); i++) {
            if (i >= threshold) break;
            Entry<String, Integer> entry = it.next();
            result.add(new DefaultKeyValue(entry.getKey(), entry.getValue()));
        }
        return result;
        
    }
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:21,代码来源:AggregatorServiceImpl.java

示例2: testHashCode

import org.apache.commons.collections.KeyValue; //导入依赖的package包/类
@[email protected]
public void testHashCode() {
	KeyValue[] predicates1 = new KeyValue[2];
	KeyValue[] predicates2 = new KeyValue[2];
	predicates1[0] = new KeyValueImp("key1", "val1");
	predicates2[0] = new KeyValueImp("key1", "val1");
	
	predicates1[1] = new KeyValueImp("key2", "val2");
	predicates2[1] = new KeyValueImp("key2", "val2");
	addressBean1 = new AddressBean("wrapper", predicates1);
	addressBean2 = new AddressBean("wrapper", predicates2);
	assertEquals(addressBean1.hashCode(), addressBean2.hashCode());
	predicates1[0] = new KeyValueImp("val1", "key1");
	assertTrue(addressBean1.hashCode() != addressBean2.hashCode());
	addressBean1 = new AddressBean("wrapper", new KeyValueImp("key1", "key2"));
	assertTrue(addressBean1.hashCode() != addressBean2.hashCode());		
}
 
开发者ID:LSIR,项目名称:gsn,代码行数:18,代码来源:TestAdressBean.java

示例3: testEqualsObject

import org.apache.commons.collections.KeyValue; //导入依赖的package包/类
@[email protected]
public void testEqualsObject() {
	KeyValue[] predicates1 = new KeyValue[2];
	KeyValue[] predicates2 = new KeyValue[2];
	predicates1[0] = new KeyValueImp("key1", "val1");
	predicates2[0] = new KeyValueImp("key1", "val1");
	
	predicates1[1] = new KeyValueImp("key2", "val2");
	predicates2[1] = new KeyValueImp("key2", "val2");
	addressBean1 = new AddressBean("wrapper", predicates1);
	addressBean2 = new AddressBean("wrapper", predicates2);
	assertEquals(addressBean1, addressBean2);
	predicates1[0] = new KeyValueImp("val1", "key1");
	assertFalse(addressBean1.equals(addressBean2));
	addressBean1 = new AddressBean("wrapper", new KeyValueImp("key1", "key2"));
	assertFalse(addressBean1.equals(addressBean2));	
}
 
开发者ID:LSIR,项目名称:gsn,代码行数:18,代码来源:TestAdressBean.java

示例4: getRPCFriendlyAddressing

import org.apache.commons.collections.KeyValue; //导入依赖的package包/类
public String[][] getRPCFriendlyAddressing() {
	String[][] toReturn = new String[this.addressing.length][2] ;
	for(int i=0;i<toReturn.length;i++)
		for (KeyValue val : this.addressing) {
			toReturn[i][0] = ( String ) val.getKey( );
			toReturn[i][1] = ( String ) val.getValue( );
		}
	return toReturn;
}
 
开发者ID:LSIR,项目名称:gsn,代码行数:10,代码来源:VSensorConfig.java

示例5: getAddressingKeys

import org.apache.commons.collections.KeyValue; //导入依赖的package包/类
public String [ ] getAddressingKeys ( ) {
	final String result[] = new String [ this.getAddressing( ).length ];
	int counter = 0;
	for ( final KeyValue predicate : this.getAddressing( ) )
		result[ counter++ ] = ( String ) predicate.getKey( );
	return result;
}
 
开发者ID:LSIR,项目名称:gsn,代码行数:8,代码来源:VSensorConfig.java

示例6: getAddressingValues

import org.apache.commons.collections.KeyValue; //导入依赖的package包/类
public String [ ] getAddressingValues ( ) {
	final String result[] = new String [ this.getAddressing( ).length ];
	int counter = 0;
	for ( final KeyValue predicate : this.getAddressing( ) )
		result[ counter++ ] = ( String ) predicate.getValue( );
	return result;
}
 
开发者ID:LSIR,项目名称:gsn,代码行数:8,代码来源:VSensorConfig.java

示例7: getMainClassInitialParams

import org.apache.commons.collections.KeyValue; //导入依赖的package包/类
/**
 * Note that the key and value both are trimmed before being inserted into
 * the data strcture.
 * 
 * @return
 */
public TreeMap < String , String > getMainClassInitialParams ( ) {
	if ( !this.isGetMainClassInitParamsInitialized ) {
		this.isGetMainClassInitParamsInitialized = true;
		for ( final KeyValue param : this.mainClassInitialParams ) {
			this.mainClassInitParams.put( param.getKey( ).toString( ).toLowerCase( ) , param.getValue( ).toString( ) );
		}
	}
	return this.mainClassInitParams;
}
 
开发者ID:LSIR,项目名称:gsn,代码行数:16,代码来源:VSensorConfig.java

示例8: toString

import org.apache.commons.collections.KeyValue; //导入依赖的package包/类
public String toString ( ) {
	final StringBuilder builder = new StringBuilder( "Input Stream [" );
	for ( final InputStream inputStream : this.getInputStreams( ) ) {
		builder.append( "Input-Stream-Name" ).append( inputStream.getInputStreamName( ) );
		builder.append( "Input-Stream-Query" ).append( inputStream.getQuery( ) );
		builder.append( " Stream-Sources ( " );
		if ( inputStream.getSources( ) == null )
			builder.append( "null" );
		else
			for ( final StreamSource ss : inputStream.getSources( ) ) {
				builder.append( "Stream-Source Alias : " ).append( ss.getAlias( ) );
				for ( final AddressBean addressing : ss.getAddressing( ) ) {
					builder.append( "Stream-Source-wrapper >" ).append( addressing.getWrapper( ) ).append( "< with addressign predicates : " );
					for ( final KeyValue keyValue : addressing.getPredicates( ) )
						builder.append( "Key=" ).append( keyValue.getKey( ) ).append( "Value=" ).append( keyValue.getValue( ) );
				}
				builder.append( " , " );
			}
		builder.append( ")" );
	}
	builder.append( "]" );
	return "VSensorConfig{" + "name='" + this.name + '\'' + ", priority=" + this.priority + ", mainClass='" + this.mainClass + '\'' 
	+ ", description='" + this.description + '\'' + ", outputStreamRate=" + this.outputStreamRate
	+ ", addressing=" + this.addressing + ", outputStructure=" + this.outputStructure + ", storageHistorySize='" + this.storageHistorySize + '\'' + builder.toString( )
	+ ", mainClassInitialParams=" + this.mainClassInitialParams + ", lastModified=" + this.lastModified + ", fileName='" + this.fileName + '\'' + ", logger=" + this.logger + ", nameInitialized="
	+ this.nameInitialized + ", isStorageCountBased=" + this.isStorageCountBased + ", parsedStorageSize=" + this.parsedStorageSize + '}';
}
 
开发者ID:LSIR,项目名称:gsn,代码行数:28,代码来源:VSensorConfig.java

示例9: preprocess_addressing

import org.apache.commons.collections.KeyValue; //导入依赖的package包/类
public void preprocess_addressing() {
	if (!addressing_processed) {
		for (KeyValue kv:getAddressing())
			if (kv.getKey().toString().equalsIgnoreCase("altitude"))
				cached_altitude=Double.parseDouble(kv.getValue().toString());
			else if (kv.getKey().toString().equalsIgnoreCase("longitude"))
				cached_longitude=Double.parseDouble(kv.getValue().toString());
			else if (kv.getKey().toString().equalsIgnoreCase("latitude"))
				cached_latitude=Double.parseDouble(kv.getValue().toString());
		addressing_processed=true;
	}
}
 
开发者ID:LSIR,项目名称:gsn,代码行数:13,代码来源:VSensorConfig.java

示例10: AddressBean

import org.apache.commons.collections.KeyValue; //导入依赖的package包/类
public AddressBean ( final String wrapper , KeyValue... newPredicates ) {
	this.wrapper = wrapper;
	if (newPredicates == null)
		this.predicates=EMPTY_PREDICATES;
	else
		this.predicates = newPredicates;
}
 
开发者ID:LSIR,项目名称:gsn,代码行数:8,代码来源:AddressBean.java

示例11: getPredicateValueWithException

import org.apache.commons.collections.KeyValue; //导入依赖的package包/类
public String getPredicateValueWithException ( String key ) {
	key = key.trim( );
	for (  KeyValue predicate : this.predicates ) {
		if ( predicate.getKey( ).toString( ).trim( ).equalsIgnoreCase( key ) ) {
			final String value = ( String ) predicate.getValue( );
			if (value.trim().length()>0)
				return ( value);
		}
	}
	throw new RuntimeException("The required parameter: >"+key+"<+ is missing.from the virtual sensor configuration file.");
}
 
开发者ID:LSIR,项目名称:gsn,代码行数:12,代码来源:AddressBean.java

示例12: getPredicateValue

import org.apache.commons.collections.KeyValue; //导入依赖的package包/类
/**
 * Note that the key for the value is case insensitive.
 * 
 * @param key
 * @return
 */

public String getPredicateValue ( String key ) {
	key = key.trim( );
	for (  KeyValue predicate : this.predicates ) {
		if ( predicate.getKey( ).toString( ).trim( ).equalsIgnoreCase( key ) ) return ( ( String ) predicate.getValue( ));
	}
	return null;
}
 
开发者ID:LSIR,项目名称:gsn,代码行数:15,代码来源:AddressBean.java

示例13: toString

import org.apache.commons.collections.KeyValue; //导入依赖的package包/类
public String toString ( ) {
	final StringBuffer result = new StringBuffer( "[" ).append( this.getWrapper( ) );
	for ( final KeyValue predicate : this.predicates ) {
		result.append( predicate.getKey( ) + " = " + predicate.getValue( ) + "," );
	}
	result.append( "]" );
	return result.toString( );
}
 
开发者ID:LSIR,项目名称:gsn,代码行数:9,代码来源:AddressBean.java

示例14: testConnectToExistingMySQLDB

import org.apache.commons.collections.KeyValue; //导入依赖的package包/类
public void testConnectToExistingMySQLDB ( ) {
   StreamExporterVirtualSensor vs = new StreamExporterVirtualSensor( );
   ArrayList < KeyValue > params = new ArrayList < KeyValue >( );
   params.add( new KeyValueImp( StreamExporterVirtualSensor.PARAM_URL , url ) );
   params.add( new KeyValueImp( StreamExporterVirtualSensor.PARAM_USER , user ) );
   params.add( new KeyValueImp( StreamExporterVirtualSensor.PARAM_PASSWD , passwd ) );
   config.setMainClassInitialParams( params );
   vs.setVirtualSensorConfiguration( config );
   assertTrue( vs.initialize( ) );
}
 
开发者ID:LSIR,项目名称:gsn,代码行数:11,代码来源:TestStreamExporterVirtualSensor.java

示例15: testReadColumns

import org.apache.commons.collections.KeyValue; //导入依赖的package包/类
@Test(groups = {"unit"})
public void testReadColumns() throws Exception {
    Map<String, String> testResultMap = new HashMap<String,String>();
    testResultMap.put(columnNames.get(0), columnValues.get(0));
    testResultMap.put(columnNames.get(1), columnValues.get(1));

    ColumnSlice columnSlice = mock(ColumnSlice.class);
    HColumn column1 = mock(HColumn.class);
    HColumn column2 = mock(HColumn.class);

    when(column1.getName()).thenReturn(columnNames.get(0));
    when(column1.getValue()).thenReturn(columnValues.get(0));
    when(column2.getName()).thenReturn(columnNames.get(1));
    when(column2.getValue()).thenReturn(columnValues.get(1));

    when(columnSlice.getColumns()).thenReturn(Arrays.asList(column1, column2));
    when(executionResult.get()).thenReturn(columnSlice);

    //=========================
    List<KeyValue> actualResult = columnFamilyTestDao.readColumns(rowKey,
                                                                  new ColumnMapper<KeyValue,String,String>() {
        @Override
        public KeyValue mapColumn(String columnName, String columnValue) {
            return new DefaultKeyValue(columnName, columnValue);
        }
    });
    //=========================

    Map<String,String> resultMap = new HashMap<String,String>();
    for (KeyValue kv : actualResult) {
        resultMap.put((String)kv.getKey(), (String)kv.getValue());
    }

    assertEquals(resultMap, testResultMap);
}
 
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:36,代码来源:ColumnFamilyTemplateTest.java


注:本文中的org.apache.commons.collections.KeyValue类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。