當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。