use of com.webobjects.appserver.WOAssociation in project wonder-slim by undur.
the class WOHelperFunctionParser method createDeclaration.
public static WODeclaration createDeclaration(String declarationName, String declarationType, NSMutableDictionary associations) {
WODeclaration declaration = new WODeclaration(declarationName, declarationType, associations);
if (WOHelperFunctionParser._debugSupport && associations != null && associations.objectForKey(WOHTMLAttribute.Debug) == null) {
// associations.setObjectForKey(new WOConstantValueAssociation(Boolean.TRUE), WOHTMLAttribute.Debug);
Enumeration associationsEnum = associations.keyEnumerator();
while (associationsEnum.hasMoreElements()) {
String bindingName = (String) associationsEnum.nextElement();
WOAssociation association = (WOAssociation) associations.objectForKey(bindingName);
association.setDebugEnabledForBinding(bindingName, declarationName, declarationType);
association._setDebuggingEnabled(false);
}
}
return declaration;
}
use of com.webobjects.appserver.WOAssociation 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