use of freemarker.debug.DebugModel in project liferay-ide by liferay.
the class FMValue method getSequenceDetailString.
private String getSequenceDetailString(DebugModel model) {
StringBuilder sb = new StringBuilder();
sb.append('[');
try {
for (int i = 0; i < model.size(); i++) {
final DebugModel val = model.get(i);
final String value = getModelDetailString(val);
if (value != null) {
sb.append(value);
sb.append(',');
}
}
} catch (Exception e) {
sb.append(e.getMessage());
}
String value = sb.toString();
return value.endsWith(",") ? value.replaceFirst(",$", "]") : value;
}
use of freemarker.debug.DebugModel in project liferay-ide by liferay.
the class FMValue method getVariables.
public IVariable[] getVariables() throws DebugException {
if (this.variables == null) {
List<IVariable> vars = new ArrayList<IVariable>();
try {
int types = this.debugModel.getModelTypes();
if (isHashType(types)) {
try {
String[] keys = this.debugModel.keys();
DebugModel[] vals = this.debugModel.get(keys);
for (int i = 0; i < keys.length; i++) {
DebugModel hashValue = vals[i];
if (isValidVariable(hashValue)) {
vars.add(new FMVariable(stackFrame, keys[i], hashValue));
}
}
} catch (ClassCastException cce) {
// ignore IDE-1082
}
} else if (isCollectionType(types)) {
// String[] keys = this.debugModel.keys();
// if( isValidVariable( hashValue ) )
// {
// vars.add( new FMVariable( stackFrame, key , debugModel ) );
// }
} else if (isSequenceType(types) && isValidSequence(this.debugModel)) {
int length = this.debugModel.size();
DebugModel[] vals = this.debugModel.get(0, length);
for (int i = 0; i < length; i++) {
if (isValidVariable(vals[i])) {
vars.add(new FMVariable(stackFrame, Integer.toString(i), vals[i]));
}
}
} else if (isStringType(types) || isNumberType(types) || isBooleanType(types) || isDateType(types)) {
// no variables
} else {
System.out.println("Unknown value: " + getReferenceTypeName(this.debugModel));
}
} catch (Exception e) {
e.printStackTrace();
}
this.variables = vars.toArray(new IVariable[vars.size()]);
sortVariables(this.variables);
}
return this.variables;
}
use of freemarker.debug.DebugModel in project liferay-ide by liferay.
the class FMValue method getCollectionDetailString.
private String getCollectionDetailString(DebugModel model) {
StringBuilder sb = new StringBuilder();
sb.append('[');
try {
for (int i = 0; i < model.size(); i++) {
final DebugModel val = model.get(i);
final String value = getModelDetailString(val);
if (value != null) {
sb.append(value);
sb.append(',');
}
}
} catch (Exception e) {
sb.append(e.getMessage());
}
String value = sb.toString();
return value.endsWith(",") ? value.replaceFirst(",$", "]") : value;
}
use of freemarker.debug.DebugModel in project liferay-ide by liferay.
the class FMValue method getHashDetailString.
private String getHashDetailString(DebugModel model) {
StringBuilder sb = new StringBuilder();
sb.append('{');
try {
for (String key : model.keys()) {
final DebugModel val = model.get(key);
final String value = getModelDetailString(val);
if (value != null) {
sb.append(key);
sb.append('=');
sb.append(value);
sb.append(',');
}
}
} catch (Exception e) {
sb.append(e.getMessage());
}
String value = sb.toString();
return value.endsWith(",") ? value.replaceFirst(",$", "}") : value;
}
use of freemarker.debug.DebugModel in project freemarker by apache.
the class RmiDebugModelImpl method get.
public DebugModel[] get(int fromIndex, int toIndex) throws TemplateModelException, RemoteException {
DebugModel[] dm = new DebugModel[toIndex - fromIndex];
TemplateSequenceModel s = (TemplateSequenceModel) model;
for (int i = fromIndex; i < toIndex; i++) {
dm[i - fromIndex] = getDebugModel(s.get(i));
}
return dm;
}
Aggregations