use of com.webobjects.foundation.NSArray in project wonder-slim by undur.
the class ERXStats method logStatisticsForOperation.
/**
* Logs the messages since the last call to initStatistics() ordered by some
* key. Note that no log message is output if there aren't any values
*
* @param operation
* operation to sort on ("sum", "count", "min", "max", "avg", "key")
*/
public static void logStatisticsForOperation(Logger statsLog, String operation) {
if (statsLog.isDebugEnabled()) {
NSMutableDictionary statistics = ERXStats.statistics();
if (statistics != null) {
synchronized (statistics) {
// NSArray values = ERXArrayUtilities.sortedArraySortedWithKey(statistics.allValues(), operation);
// FIXME: This used to be sorted. Does it matter? Do I care?
NSArray values = statistics.allValues();
if (values.count() > 0) {
Long startTime = (Long) ERXThreadStorage.valueForKey(ERXStats.STATS_START_TIME_KEY);
Long lastTime = (Long) ERXThreadStorage.valueForKey(ERXStats.STATS_LAST_TIME_KEY);
long currentTime = System.currentTimeMillis();
String result = NSPropertyListSerialization.stringFromPropertyList(values);
// result = result.replaceAll("\\n\\t", "\n\t\t");
// result = result.replaceAll("\\n", "\n\t\t");
statsLog.debug((startTime != null ? "Time since init " + (currentTime - startTime.longValue()) + " ms" : "") + (lastTime != null ? ", last log " + (currentTime - lastTime.longValue()) + " ms" : "") + ", total cnt/sum: " + statistics.allValues().valueForKeyPath("@sum.count") + "/" + statistics.allValues().valueForKeyPath("@sum.sum") + " (cnt/sum : min/max/avg|trace cnt -> key) = " + result);
ERXThreadStorage.takeValueForKey(Long.valueOf(currentTime), ERXStats.STATS_LAST_TIME_KEY);
}
}
}
}
}
use of com.webobjects.foundation.NSArray in project wonder-slim by undur.
the class WODictionaryRepetition method dictionary.
public NSDictionary dictionary() {
if (_dictionary == null) {
_dictionary = (NSDictionary) _WOJExtensionsUtil.valueForBindingOrNull("dictionary", this);
if (_dictionary == null) {
_dictionary = NSDictionary.EmptyDictionary;
_keyList = NSArray.EmptyArray;
} else {
_keyList = _dictionary.allKeys();
_keyList = EOSortOrdering.sortedArrayUsingKeyOrderArray(_keyList, new NSArray<>(new EOSortOrdering("toString", EOSortOrdering.CompareAscending)));
}
}
return _dictionary;
}
use of com.webobjects.foundation.NSArray in project wonder-slim by undur.
the class WOHelperFunctionDeclarationParser method _associationsForDictionaryString.
private NSMutableDictionary _associationsForDictionaryString(String declarationHeader, String declarationBody) throws WOHelperFunctionDeclarationFormatException {
NSMutableDictionary associations = new NSMutableDictionary();
String trimmedDeclarationBody = declarationBody.trim();
if (!trimmedDeclarationBody.startsWith("{") && !trimmedDeclarationBody.endsWith("}")) {
throw new WOHelperFunctionDeclarationFormatException("<WOHelperFunctionDeclarationParser> Internal inconsistency : invalid dictionary for declaration:\n" + declarationHeader + " " + declarationBody);
}
int declarationBodyLength = trimmedDeclarationBody.length();
if (declarationBodyLength <= 2) {
return associations;
}
trimmedDeclarationBody = trimmedDeclarationBody.substring(1, declarationBodyLength - 1).trim();
NSArray bindings = NSArray.componentsSeparatedByString(trimmedDeclarationBody, ";");
Enumeration bindingsEnum = bindings.objectEnumerator();
do {
if (!bindingsEnum.hasMoreElements()) {
break;
}
String binding = ((String) bindingsEnum.nextElement()).trim();
if (binding.length() != 0) {
int equalsIndex = binding.indexOf('=');
if (equalsIndex < 0) {
throw new WOHelperFunctionDeclarationFormatException("<WOHelperFunctionDeclarationParser> Invalid line. No equal in line:\n" + binding + "\nfor declaration:\n" + declarationHeader + " " + declarationBody);
}
String key = binding.substring(0, equalsIndex).trim();
if (key.length() == 0) {
throw new WOHelperFunctionDeclarationFormatException("<WOHelperFunctionDeclarationParser> Missing binding in line:\n" + binding + "\nfor declaration:\n" + declarationHeader + " " + declarationBody);
}
String value = binding.substring(equalsIndex + 1).trim();
if (value.length() == 0) {
throw new WOHelperFunctionDeclarationFormatException("<WOHelperFunctionDeclarationParser> Missing value in line:\n" + binding + "\nfor declaration:\n" + declarationHeader + " " + declarationBody);
}
WOAssociation association = WOHelperFunctionDeclarationParser._associationWithKey(value, _quotedStrings);
Object quotedString = _quotedStrings.objectForKey(key);
if (quotedString != null) {
associations.setObjectForKey(association, quotedString);
} else {
associations.setObjectForKey(association, key);
}
}
} while (true);
// }
return associations;
}
Aggregations