use of com.webobjects.foundation.NSMutableDictionary in project wonder-slim by undur.
the class ERXAjaxSession method _permanentPageCache.
/**
* Returns the permanent page cache. Initializes it if needed.
*/
protected NSMutableDictionary _permanentPageCache() {
if (_permanentPageCache == null) {
_permanentPageCache = new NSMutableDictionary(64);
_permanentContextIDArray = new NSMutableArray(64);
}
return _permanentPageCache;
}
use of com.webobjects.foundation.NSMutableDictionary in project wonder-slim by undur.
the class WOHelperFunctionParser method parseInlineBindings.
protected WODeclaration parseInlineBindings(String tag, int colonIndex) throws WOHelperFunctionHTMLFormatException {
StringBuffer keyBuffer = new StringBuffer();
StringBuffer valueBuffer = new StringBuffer();
StringBuffer elementTypeBuffer = new StringBuffer();
NSMutableDictionary associations = new NSMutableDictionary();
StringBuffer currentBuffer = elementTypeBuffer;
boolean changeBuffers = false;
boolean inQuote = false;
int length = tag.length();
for (int index = colonIndex + 1; index < length; index++) {
char ch = tag.charAt(index);
if (!inQuote && (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')) {
changeBuffers = true;
} else if (!inQuote && ch == '=') {
changeBuffers = true;
} else if (inQuote && ch == '\\') {
index++;
if (index == length) {
throw new WOHelperFunctionHTMLFormatException("'" + tag + "' has a '\\' as the last character.");
}
if (tag.charAt(index) == '\"') {
currentBuffer.append("\"");
} else if (tag.charAt(index) == 'n') {
currentBuffer.append('\n');
} else if (tag.charAt(index) == 'r') {
currentBuffer.append('\r');
} else if (tag.charAt(index) == 't') {
currentBuffer.append('\t');
} else {
currentBuffer.append('\\');
currentBuffer.append(tag.charAt(index));
}
} else {
if (changeBuffers) {
if (currentBuffer == elementTypeBuffer) {
currentBuffer = keyBuffer;
} else if (currentBuffer == keyBuffer) {
currentBuffer = valueBuffer;
} else if (currentBuffer == valueBuffer) {
parseInlineAssociation(keyBuffer, valueBuffer, associations);
currentBuffer = keyBuffer;
}
currentBuffer.setLength(0);
changeBuffers = false;
}
if (ch == '"') {
inQuote = !inQuote;
}
currentBuffer.append(ch);
}
}
if (inQuote) {
throw new WOHelperFunctionHTMLFormatException("'" + tag + "' has a quote left open.");
}
if (keyBuffer.length() > 0) {
if (valueBuffer.length() > 0) {
parseInlineAssociation(keyBuffer, valueBuffer, associations);
} else {
throw new WOHelperFunctionHTMLFormatException("'" + tag + "' defines a key but no value.");
}
}
String elementType = elementTypeBuffer.toString();
String shortcutType = (String) WOHelperFunctionTagRegistry.tagShortcutMap().objectForKey(elementType);
if (shortcutType != null) {
elementType = shortcutType;
} else if (elementType.startsWith(WO_REPLACEMENT_MARKER)) {
// Acts only on tags, where we have "dynamified" inside the tag parser
// this takes the value found after the "wo:" part in the element and generates a WOGenericContainer with that value
// as the elementName binding
elementType = elementType.replaceAll(WO_REPLACEMENT_MARKER, "");
associations.setObjectForKey(WOHelperFunctionAssociation.associationWithValue(elementType), "elementName");
elementType = "WOGenericContainer";
}
String elementName;
synchronized (this) {
elementName = "_" + elementType + "_" + _inlineBindingCount;
_inlineBindingCount++;
}
WOTagProcessor tagProcessor = (WOTagProcessor) WOHelperFunctionTagRegistry.tagProcessorMap().objectForKey(elementType);
WODeclaration declaration;
if (tagProcessor == null) {
declaration = WOHelperFunctionParser.createDeclaration(elementName, elementType, associations);
} else {
declaration = tagProcessor.createDeclaration(elementName, elementType, associations);
}
_declarations.setObjectForKey(declaration, elementName);
processDeclaration(declaration);
return declaration;
}
use of com.webobjects.foundation.NSMutableDictionary in project wonder-slim by undur.
the class ERXComponentUtilities method _queryParametersInComponent.
public static NSMutableDictionary _queryParametersInComponent(NSMutableDictionary associations, WOComponent component) {
NSMutableDictionary queryParameters = new NSMutableDictionary();
Enumeration keyEnum = associations.keyEnumerator();
while (keyEnum.hasMoreElements()) {
String key = (String) keyEnum.nextElement();
WOAssociation association = (WOAssociation) associations.valueForKey(key);
Object associationValue = association.valueInComponent(component);
if (associationValue != null) {
queryParameters.setObjectForKey(associationValue, key.substring(1));
}
}
return queryParameters;
}
use of com.webobjects.foundation.NSMutableDictionary in project wonder-slim by undur.
the class ERXStatisticsStore method statistics.
@Override
public NSDictionary statistics() {
NSDictionary stats = super.statistics();
NSMutableDictionary fixed = stats.mutableClone();
for (Enumeration enumerator = stats.keyEnumerator(); enumerator.hasMoreElements(); ) {
Object key = enumerator.nextElement();
Object value = stats.objectForKey(key);
fixed.setObjectForKey(fix(value), key);
}
stats = fixed;
return stats;
}
use of com.webobjects.foundation.NSMutableDictionary 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);
}
}
}
}
}
Aggregations