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


Java Map.toString方法代码示例

本文整理汇总了Java中java.util.Map.toString方法的典型用法代码示例。如果您正苦于以下问题:Java Map.toString方法的具体用法?Java Map.toString怎么用?Java Map.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Map的用法示例。


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

示例1: formatData

import java.util.Map; //导入方法依赖的package包/类
private String formatData ( final Map<String, String> data, final int maxLen )
{
    if ( data == null )
    {
        return null;
    }

    final String str = data.toString ();
    if ( maxLen > 0 && str.length () > maxLen )
    {
        return str.substring ( 0, maxLen ) + "…";
    }
    else
    {
        return str;
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:18,代码来源:DiffEntryLabelProvider.java

示例2: update

import java.util.Map; //导入方法依赖的package包/类
@Override
public void update(Entry entry, Entry existingEntry) {
    readWriteLock.writeLock().lock();

    try {
        Map<String, AttributeValue> keys = createKey(entry);
        Map<String, AttributeValueUpdate> attributes = createAttributes(entry);
        Map<String, ExpectedAttributeValue> expected = expectExists(existingEntry);

        try {
            executeUpdate(keys, attributes, expected);
        } catch (ConditionalCheckFailedException e) {
            throw new DoesNotExistException("Precondition to update entry in DynamoDB failed:" + keys.toString());
        }
    } finally {
        readWriteLock.writeLock().unlock();
    }

}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:20,代码来源:GenericDynamoDB.java

示例3: create

import java.util.Map; //导入方法依赖的package包/类
@Override
public void create(Entry entry) {
    readWriteLock.writeLock().lock();

    try {
        Map<String, AttributeValue> keys = createKey(entry);
        Map<String, AttributeValueUpdate> attributes = createAttributes(entry);
        Map<String, ExpectedAttributeValue> expected = expectNotExists();

        try {
            executeUpdate(keys, attributes, expected);
        } catch (ConditionalCheckFailedException e) {
            throw new AlreadyExistsException("DynamoDB store entry already exists:" + keys.toString());
        }
    } finally {
        readWriteLock.writeLock().unlock();
    }
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:19,代码来源:GenericDynamoDB.java

示例4: toLoggableString

import java.util.Map; //导入方法依赖的package包/类
@Override
public String toLoggableString(Object value, SessionFactoryImplementor factory)
		throws HibernateException {
	if ( value == null ) {
		return "null";
	}

	if ( entityMode == null ) {
		throw new ClassCastException( value.getClass().getName() );
	}
	Map<String,String> result = new HashMap<String, String>();
	Object[] values = getPropertyValues( value, entityMode );
	for ( int i = 0; i < propertyTypes.length; i++ ) {
		result.put( propertyNames[i], propertyTypes[i].toLoggableString( values[i], factory ) );
	}
	return StringHelper.unqualify( getName() ) + result.toString();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:ComponentType.java

示例5: toString

import java.util.Map; //导入方法依赖的package包/类
public String toString(Map namedTypedValues) throws HibernateException {
	Map result = new HashMap();
	Iterator iter = namedTypedValues.entrySet().iterator();
	while ( iter.hasNext() ) {
		Map.Entry me = (Map.Entry) iter.next();
		TypedValue tv = (TypedValue) me.getValue();
		result.put( me.getKey(), tv.getType().toString( tv.getValue(), factory ) );
	}
	return result.toString();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:11,代码来源:Printer.java

示例6: expectedToString

import java.util.Map; //导入方法依赖的package包/类
private String expectedToString(Set<Entry<K, V>> entries) {
  Map<K, V> reference = new LinkedHashMap<K, V>();
  for (Map.Entry<K, V> entry : entries) {
    reference.put(entry.getKey(), entry.getValue());
  }
  return reference.toString();
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:8,代码来源:MapToStringTester.java

示例7: testKeybindings

import java.util.Map; //导入方法依赖的package包/类
public void testKeybindings() {
    MimeTypesTracker tracker = MimeTypesTracker.get(KeyMapsStorage.ID, "Editors");
    Set<String> mimeTypes = new HashSet<String>(tracker.getMimeTypes());
    Set<String> profiles = EditorSettings.getDefault().getKeyMapProfiles();
    
    for(String profile : profiles) {
        List<MultiKeyBinding> commonKeybindings = EditorSettings.getDefault().getKeyBindingSettings(new String[0]).getKeyBindings(profile);
        Map<String, String> commonNorm = normalize(commonKeybindings);

        String commonCurrent = commonNorm.toString();
        String commonGolden = fromFile("KB--" + profile);

        assertEquals("Wrong keybindings for '', profile '" + profile + "'", commonGolden, commonCurrent);

        for(String mimeType : mimeTypes) {
            List<MultiKeyBinding> keybindings = EditorSettings.getDefault().getKeyBindingSettings(mimeType.length() == 0 ? new String[0] : new String [] { mimeType }).getKeyBindings(profile);

            Map<String, String> mimeTypeNorm = new TreeMap<String, String>();
            Map<String, String> norm = normalize(keybindings);
            
            mimeTypeNorm.putAll(commonNorm);
            mimeTypeNorm.putAll(norm);
            
            String current = mimeTypeNorm.toString();
            String golden = fromFile("KB-" + mimeType.replace("/", "-") + "-" + profile);
            
            assertEquals("Wrong keybindings for '" + mimeType + "', profile '" + profile + "'", golden, current);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:Pre90403Phase1CompatibilityTest.java

示例8: processMap

import java.util.Map; //导入方法依赖的package包/类
/**
 * This method is used when "actualValue" or "expectedValue" are json object and not simple strings.
 * In particular it can manage:
 * - regular expression extraction
 * - occurrence of a given string in another string
 * - ... TBD
 * @param map it is the map representing the json object of the "actualValue" or "expectedValue"
 * @param response is the response retrieved from the service under test.
 * @return the final string to use for the verification step
 */
private String processMap(Map map, Response response) {
    String outputStr = "";
    if (map.containsKey(REGEXP_JSON_ELEMENT) && map.containsKey(STRING_TO_PARSE_JSON_ELEMENT)) {
        outputStr = regexpExtractorProcessing(map, response);
    } else if (map.containsKey(REGEXP_MATCH_JSON_ELEMENT) && map.containsKey(STRING_TO_PARSE_JSON_ELEMENT)) {
        outputStr = regexpMatchExtractorProcessing(map, response);
    } else if (map.containsKey(OCCURRENCE_JSON_ELEMENT) && map.containsKey(STRING_TO_PARSE_JSON_ELEMENT)) {
        outputStr = occurrenceOfProcessing(map, response);
    } else {
        throw new HeatException(logUtils.getExceptionDetails() + "configuration " + map.toString() + " not supported");
    }
    return outputStr;
}
 
开发者ID:HotelsDotCom,项目名称:heat,代码行数:24,代码来源:DataExtractionSupport.java

示例9: getAccessTokenFromWeixin

import java.util.Map; //导入方法依赖的package包/类
public static String getAccessTokenFromWeixin() throws Exception {
    String body = HttpRequest.get("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" +
            Const.WX_APP_ID + "&secret=" + Const.WX_APP_SECRET).body();
    Map result = JSON.parseObject(body, Map.class);
    String accessToken = (String) result.get("access_token");
    if (accessToken == null) {
        throw new Exception(result.toString());
    }
    return accessToken;
}
 
开发者ID:luckyyeah,项目名称:YiDu-Novel,代码行数:11,代码来源:WeixinUtils.java

示例10: toString

import java.util.Map; //导入方法依赖的package包/类
/** Returns a map from option keys to the enabled status of the option. */
@Override
public String toString() {
    Map<String,Boolean> result = new HashMap<>();
    for (Map.Entry<String,JMenuItem> entry : this.itemMap.entrySet()) {
        result.put(entry.getKey(), entry.getValue()
            .isSelected());
    }
    return result.toString();
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:11,代码来源:Options.java

示例11: toString

import java.util.Map; //导入方法依赖的package包/类
/**
 * Renders an entity to a string.
 *
 * @param entityName the entity name
 * @param entity an actual entity object, not a proxy!
 * @return the entity rendered to a string
 */
public String toString(String entityName, Object entity) throws HibernateException {
	EntityPersister entityPersister = factory.getEntityPersister( entityName );

	if ( entityPersister == null ) {
		return entity.getClass().getName();
	}

	Map<String,String> result = new HashMap<String,String>();

	if ( entityPersister.hasIdentifierProperty() ) {
		result.put(
			entityPersister.getIdentifierPropertyName(),
			entityPersister.getIdentifierType().toLoggableString( entityPersister.getIdentifier( entity ), factory )
		);
	}

	Type[] types = entityPersister.getPropertyTypes();
	String[] names = entityPersister.getPropertyNames();
	Object[] values = entityPersister.getPropertyValues( entity );
	for ( int i=0; i<types.length; i++ ) {
		if ( !names[i].startsWith("_") ) {
			String strValue = values[i]==LazyPropertyInitializer.UNFETCHED_PROPERTY ?
				values[i].toString() :
				types[i].toLoggableString( values[i], factory );
			result.put( names[i], strValue );
		}
	}
	return entityName + result.toString();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:37,代码来源:EntityPrinter.java

示例12: getHeadersAsText

import java.util.Map; //导入方法依赖的package包/类
public static String getHeadersAsText(HttpServletRequest request) {
    Map<String, String> headers = new HashMap<>();
    Enumeration<String> names = request.getHeaderNames();
    while (names.hasMoreElements()) {
        String name = names.nextElement();
        if (!name.equals(AUTHORIZATION)) {
            headers.put(name, request.getHeader(name));
        }
    }
    return headers.toString();
}
 
开发者ID:mkopylec,项目名称:errorest-spring-boot-starter,代码行数:12,代码来源:HttpUtils.java

示例13: CommandResponse

import java.util.Map; //导入方法依赖的package包/类
public CommandResponse(Map<String, Integer> input) {
	responseType = "WordCount";
	this.returnVal = input.toString();
}
 
开发者ID:Streus,项目名称:Project-SADS,代码行数:5,代码来源:CommandResponse.java

示例14: toString

import java.util.Map; //导入方法依赖的package包/类
@Override
public String toString() {
    Map<Attribute<?>, Object> sorted = new TreeMap<Attribute<?>, Object>(ATTRIBUTE_NAME_COMPARATOR);
    sorted.putAll(attributes);
    return sorted.toString();
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:7,代码来源:ImmutableAttributes.java

示例15: update

import java.util.Map; //导入方法依赖的package包/类
private void update(Map<String, String> tuple) {
	// TODO Auto-generated method stub
	//System.out.println("String" + tuple);
	resultString += tuple.toString()+ "\n";
}
 
开发者ID:dream-lab,项目名称:echo,代码行数:6,代码来源:EdgentFilter_RBI.java


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