• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java KeyValue类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: evaluate

import org.apache.commons.collections.KeyValue; //导入依赖的package包/类
public void evaluate(LoggedInInfo loggedInInfo, Denominator deno, Numerator numer,List<KeyValue> additionalFields){
        denominator = deno;
        numerator = numer;
        List demoList = deno.getDenominatorList();
        denominatorCount = demoList.size();
        setReportResultList(new ArrayList<Hashtable<String,Object>>());
        for (int i = 0; i < demoList.size(); i++){
            String demo = (String) demoList.get(i);
            boolean bool = numer.evaluate(loggedInInfo, demo);
            //Object obj = numer.getOutputValues();  // PROBLEM IS THAT THIS WILL ALWAYS HAVE A VALUE
            Hashtable<String,Object> h = new Hashtable<String,Object>();
            h.put("_demographic_no",demo);
            h.put("_report_result",new Boolean(bool));

            if (additionalFields != null){
                for(KeyValue field:additionalFields){
                    String key = (String) field.getKey();
                    String val = (String) field.getValue();

                    EctMeasurementsDataBeanHandler ect = new EctMeasurementsDataBeanHandler(Integer.valueOf(demo), val);
                    Collection<EctMeasurementsDataBean> v = ect.getMeasurementsDataVector();
                    //Execute for the value and attach it to the key in the hashtable
                    //Object obj =
                    if(v.iterator().hasNext()){
                        h.put(key, v.iterator().next());
                    }

                }
            }



            getReportResultList().add(h);
//            if (obj != null){
//                getReportResultList().add(obj);
//            }
            if (bool){
                numeratorCount++;
            }

        }

    }
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:44,代码来源:ReportEvaluator.java


示例17: getAddressing

import org.apache.commons.collections.KeyValue; //导入依赖的package包/类
/**
 * @return Returns the addressing.
 */
public  KeyValue[] getAddressing ( ) {
	return this.addressing;
}
 
开发者ID:LSIR,项目名称:gsn,代码行数:7,代码来源:VSensorConfig.java


示例18: setAddressing

import org.apache.commons.collections.KeyValue; //导入依赖的package包/类
/**
 * @param addressing The addressing to set.
 */
public void setAddressing ( KeyValue [] addressing ) {
	this.addressing = addressing;
}
 
开发者ID:LSIR,项目名称:gsn,代码行数:7,代码来源:VSensorConfig.java


示例19: setMainClassInitialParams

import org.apache.commons.collections.KeyValue; //导入依赖的package包/类
public void setMainClassInitialParams ( final ArrayList < KeyValue > mainClassInitialParams ) {
	this.mainClassInitialParams = mainClassInitialParams;
}
 
开发者ID:LSIR,项目名称:gsn,代码行数:4,代码来源:VSensorConfig.java


示例20: vsensor

import org.apache.commons.collections.KeyValue; //导入依赖的package包/类
public static VSensorConfig vsensor(VsConf vs){
 VSensorConfig v=new VSensorConfig();
 v.setMainClass(vs.processing().className());
 v.setDescription(vs.description());
 v.setName(vs.name());
 v.setIsTimeStampUnique(vs.processing().uniqueTimestamp());
 if (vs.poolSize().isDefined())
   v.setLifeCyclePoolSize(((Integer)vs.poolSize().get()));
 if (vs.processing().rate().isDefined())
   v.setOutputStreamRate(((Integer)vs.processing().rate().get()));
 v.setPriority(vs.priority());
 KeyValueImp [] addr=new KeyValueImp[vs.address().size()];
    Iterable<String> keys=JavaConversions.asJavaIterable(vs.address().keys());
    int i=0;
 for (String k:keys){
  addr[i]=new KeyValueImp(k,vs.address().apply(k));
  i++;
 }
 v.setAddressing(addr);
 InputStream[] is=new InputStream[vs.streams().size()];
 for (int j=0;j<is.length;j++){
  is[j]=stream(vs.streams().apply(j));
 }
 v.setInputStreams(is);
 if (vs.processing().webInput().isDefined()){
  WebInputConf wic=vs.processing().webInput().get();
  v.setWebParameterPassword(wic.password());
  WebInput[] wi=new WebInput[wic.commands().size()];
  for (int j=0;j<wi.length;j++){
	  wi[j]=webInput(wic.commands().apply(j));
  }
  v.setWebInput(wi);
 }
 DataField [] out=new DataField[(vs.processing().output().size())];
 for (int j=0;j<out.length;j++){
  out[j]=dataField(vs.processing().output().apply(j));
 }
 v.setOutputStructure(out);
 Map<String,String> init=vs.processing().initParams();
 ArrayList<KeyValue> ini=new ArrayList<KeyValue>();
    Iterable<String> initkeys=JavaConversions.asJavaIterable(init.keys());
 for (String ik:initkeys){
  logger.trace("keys:"+ik);
  ini.add(new KeyValueImp(ik.toLowerCase(),init.apply(ik)));
 }
 v.setMainClassInitialParams(ini);
 
 StorageConfig st=new StorageConfig();
 if (vs.storageSize().isDefined())
  st.setStorageSize(vs.storageSize().get());
 if (vs.storage().isDefined()){
StorageConf sc=vs.storage().get();
if (sc.identifier().isDefined())
  st.setIdentifier(sc.identifier().get());
st.setJdbcDriver(sc.driver());
st.setJdbcURL(sc.url());
st.setJdbcUsername(sc.user());
st.setJdbcPassword(sc.pass());		
 }
 if (st.getStorageSize()!=null || st.getJdbcURL()!=null)
v.setStorage(st);
 return v;
}
 
开发者ID:LSIR,项目名称:gsn,代码行数:64,代码来源:BeansInitializer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OrphanHLogAfterSplitException类代码示例发布时间:2022-05-22
下一篇:
Java SysSecurityHandler类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap