本文整理汇总了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;
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例13: CommandResponse
import java.util.Map; //导入方法依赖的package包/类
public CommandResponse(Map<String, Integer> input) {
responseType = "WordCount";
this.returnVal = input.toString();
}
示例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();
}
示例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";
}