
com.reprezen.genflow.swagger.doc.StructureTable Maven / Gradle / Ivy
The newest version!
package com.reprezen.genflow.swagger.doc;
import com.google.common.base.Objects;
import com.reprezen.genflow.swagger.doc.Activation;
import com.reprezen.genflow.swagger.doc.ArrayHelper;
import com.reprezen.genflow.swagger.doc.AttrDetails;
import com.reprezen.genflow.swagger.doc.AttributeHelper;
import com.reprezen.genflow.swagger.doc.BadArrayException;
import com.reprezen.genflow.swagger.doc.BadReferenceException;
import com.reprezen.genflow.swagger.doc.DocHelper;
import com.reprezen.genflow.swagger.doc.HelperHelper;
import com.reprezen.genflow.swagger.doc.HtmlHelper;
import com.reprezen.genflow.swagger.doc.Indentation;
import com.reprezen.genflow.swagger.doc.OptionHelper;
import com.reprezen.genflow.swagger.doc.RecursionHelper;
import com.reprezen.genflow.swagger.doc.RecursiveRenderException;
import com.reprezen.genflow.swagger.doc.RefHelper;
import io.swagger.models.ArrayModel;
import io.swagger.models.ComposedModel;
import io.swagger.models.Model;
import io.swagger.models.ModelImpl;
import io.swagger.models.Swagger;
import io.swagger.models.parameters.Parameter;
import io.swagger.models.parameters.SerializableParameter;
import io.swagger.models.properties.AbstractProperty;
import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.MapProperty;
import io.swagger.models.properties.ObjectProperty;
import io.swagger.models.properties.Property;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
import org.eclipse.xtext.xbase.lib.Conversions;
import org.eclipse.xtext.xbase.lib.Exceptions;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.ListExtensions;
@SuppressWarnings("all")
public class StructureTable {
@Extension
private HtmlHelper _htmlHelper = HelperHelper.getHtmlHelper();
@Extension
private AttributeHelper _attributeHelper = HelperHelper.getAttributeHelper();
@Extension
private DocHelper _docHelper = HelperHelper.getDocHelper();
@Extension
private RecursionHelper _recursionHelper = HelperHelper.getRecursionHelper();
@Extension
private ArrayHelper _arrayHelper = HelperHelper.getArrayHelper();
@Extension
private RefHelper _refHelper = HelperHelper.getRefHelper();
@Extension
private OptionHelper _optionHelper = HelperHelper.getOptionHelper();
private final String[][] cols;
public static StructureTable get(final Swagger swagger, final String[]... cols) {
return new StructureTable(swagger, cols);
}
private StructureTable(final Swagger swagger, final String[]... cols) {
this.cols = cols;
}
/**
* Public method for rendering a table describing an object
*/
public String render(final Object obj, final String name, final Object referrer) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("");
_builder.newLine();
_builder.append(" ");
String _renderHeaderRow = this.renderHeaderRow(obj);
_builder.append(_renderHeaderRow, " ");
_builder.newLineIfNotEmpty();
_builder.append(" ");
Indentation _indentation = new Indentation();
String _renderObject = this.renderObject(obj, name, referrer, _indentation);
_builder.append(_renderObject, " ");
_builder.newLineIfNotEmpty();
_builder.append("
");
_builder.newLine();
return _builder.toString();
}
private String renderObject(final Object obj, final String name, final Object referrer, final Indentation ind) {
String _xblockexpression = null;
{
final Object resolved = this._refHelper.resolve(obj);
Activation activation = null;
String _xtrycatchfinallyexpression = null;
try {
String _xblockexpression_1 = null;
{
activation = this._recursionHelper.use(resolved);
AttrDetails _attrDetails = new AttrDetails(resolved);
_xblockexpression_1 = this.render(resolved, name, referrer, ind, _attrDetails);
}
_xtrycatchfinallyexpression = _xblockexpression_1;
} catch (final Throwable _t) {
if (_t instanceof BadReferenceException) {
final BadReferenceException e = (BadReferenceException)_t;
_xtrycatchfinallyexpression = this.render(e, name, referrer, ind, null);
} else if (_t instanceof RecursiveRenderException) {
final RecursiveRenderException e_1 = (RecursiveRenderException)_t;
_xtrycatchfinallyexpression = this.render(e_1, name, referrer, ind, null);
} else if (_t instanceof BadArrayException) {
final BadArrayException e_2 = (BadArrayException)_t;
_xtrycatchfinallyexpression = this.render(e_2, name, referrer, ind, null);
} else {
throw Exceptions.sneakyThrow(_t);
}
} finally {
if (activation!=null) {
activation.close();
}
}
_xblockexpression = _xtrycatchfinallyexpression;
}
return _xblockexpression;
}
private String _render(final Object obj, final String name, final Object referrer, final Indentation ind, final AttrDetails det) {
return this.defaultRender(obj, name, referrer, ind, det);
}
private String renderHeaderRow(final Object obj) {
final Function1 _function = (String[] col) -> {
return this.renderHeaderColumn(obj, col[1]);
};
return this.wrapHeaderRow(ListExtensions.map(((List)Conversions.doWrapArray(this.cols)), _function));
}
private String renderHeaderColumn(final Object obj, final String text) {
return text;
}
private String defaultRender(final Object obj, final String name, final Object referrer, final Indentation ind, final AttrDetails det) {
StringConcatenation _builder = new StringConcatenation();
final Function1 _function = (String[] col) -> {
return this.renderColumn(obj, col[0], name, referrer, ind, det);
};
String _wrapRow = this.wrapRow(ListExtensions.map(((List)Conversions.doWrapArray(this.cols)), _function));
_builder.append(_wrapRow);
_builder.newLineIfNotEmpty();
String _renderAttrDetails = this.renderAttrDetails(obj, name, referrer, ind, det);
String _wrapRow_1 = null;
if (_renderAttrDetails!=null) {
_wrapRow_1=this.wrapRow(_renderAttrDetails, true);
}
_builder.append(_wrapRow_1);
_builder.newLineIfNotEmpty();
return _builder.toString();
}
private String renderAttrDetails(final Object obj, final String name, final Object referrer, final Indentation ind, final AttrDetails det) {
return this.renderColumn(obj, "details", name, referrer, ind, det);
}
private String _renderColumn(final Object obj, final String colAttr, final String name, final Object referrer, final Indentation ind, final AttrDetails det) {
String _xblockexpression = null;
{
final String chosenName = this.chooseName(obj, name);
String _switchResult = null;
if (colAttr != null) {
switch (colAttr) {
case "name":
String _htmlEscape = null;
if (chosenName!=null) {
_htmlEscape=this._htmlHelper.htmlEscape(chosenName);
}
String _formatName = null;
if (_htmlEscape!=null) {
_formatName=this.formatName(_htmlEscape, chosenName, obj, referrer);
}
String _indentCode = null;
if (_formatName!=null) {
_indentCode=this.indentCode(_formatName, ind);
}
_switchResult = _indentCode;
break;
case "type":
String _typeSpec = this.getTypeSpec(obj, det);
String _code = null;
if (_typeSpec!=null) {
_code=this._htmlHelper.getCode(_typeSpec);
}
_switchResult = _code;
break;
case "doc":
_switchResult = this.getDoc(obj);
break;
case "details":
CharSequence _details = null;
if (det!=null) {
_details=det.details(false);
}
String _string = null;
if (_details!=null) {
_string=_details.toString();
}
_switchResult = _string;
break;
default:
_switchResult = this.getValueForDisplay(this._attributeHelper.getAttribute(obj, colAttr));
break;
}
} else {
_switchResult = this.getValueForDisplay(this._attributeHelper.getAttribute(obj, colAttr));
}
_xblockexpression = _switchResult;
}
return _xblockexpression;
}
private String _chooseName(final Object obj, final String offeredName) {
String _xifexpression = null;
if (((offeredName != null) && offeredName.startsWith("!"))) {
_xifexpression = offeredName.substring(1);
} else {
String _rzveTypeName = this._attributeHelper.getRzveTypeName(obj);
String _name = this._attributeHelper.getName(obj);
final Function1 _function = (String it) -> {
return Boolean.valueOf((it != null));
};
_xifexpression = IterableExtensions.last(IterableExtensions.filter(Collections.unmodifiableList(CollectionLiterals.newArrayList(offeredName, _rzveTypeName, _name)), _function));
}
return _xifexpression;
}
private String formatName(final String formattedName, final String rawName, final Object obj, final Object referrer) {
String _xifexpression = null;
boolean _isRequired = this.isRequired(obj, rawName, referrer);
if (_isRequired) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("");
_builder.append(formattedName);
_builder.append("");
_xifexpression = _builder.toString();
} else {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("");
_builder_1.append(formattedName);
_builder_1.append("");
_xifexpression = _builder_1.toString();
}
return _xifexpression;
}
private boolean isRequired(final Object obj, final String name, final Object referrer) {
boolean _matched = false;
if (obj instanceof Property) {
_matched=true;
return ((Property)obj).getRequired();
}
if (!_matched) {
if (obj instanceof Parameter) {
_matched=true;
return ((Parameter)obj).getRequired();
}
}
if (!_matched) {
if (obj instanceof Model) {
_matched=true;
return this.getRequiredProperties(referrer).contains(name);
}
}
throw new IllegalArgumentException(
"Named item is represented by neither a Property, a Parameter, nor a Model");
}
private List getRequiredProperties(final Object referrer) {
if ((referrer != null)) {
boolean _matched = false;
if (referrer instanceof ModelImpl) {
_matched=true;
List _elvis = null;
List _required = ((ModelImpl)referrer).getRequired();
if (_required != null) {
_elvis = _required;
} else {
_elvis = Collections.unmodifiableList(CollectionLiterals.newArrayList());
}
return _elvis;
}
if (!_matched) {
if (referrer instanceof ObjectProperty) {
_matched=true;
List _elvis = null;
List _requiredProperties = ((ObjectProperty)referrer).getRequiredProperties();
if (_requiredProperties != null) {
_elvis = _requiredProperties;
} else {
_elvis = Collections.unmodifiableList(CollectionLiterals.newArrayList());
}
return _elvis;
}
}
}
return Collections.unmodifiableList(CollectionLiterals.newArrayList());
}
private String _getTypeSpec(final Object obj, final AttrDetails det) {
return this.getDefaultTypeSpec(obj, det);
}
private String getDefaultTypeSpec(final Object obj, final AttrDetails det) {
String _type = this._attributeHelper.getType(obj);
String _rzveTypeName = this._attributeHelper.getRzveTypeName(obj);
final Function1 _function = (String it) -> {
return Boolean.valueOf((it != null));
};
return IterableExtensions.last(IterableExtensions.filter(Collections.unmodifiableList(CollectionLiterals.newArrayList(_type, _rzveTypeName)), _function));
}
private String _getDoc(final Object obj) {
String _description = this._attributeHelper.getDescription(obj);
String _docHtml = null;
if (_description!=null) {
_docHtml=this._docHelper.getDocHtml(_description);
}
return _docHtml;
}
/**
* ModelImpl covers both object schemas and primitive type schemas
*/
private String _render(final ModelImpl model, final String name, final Object referrer, final Indentation ind, final AttrDetails det) {
String _xblockexpression = null;
{
Property _additionalProperties = model.getAdditionalProperties();
Object _safeResolve = null;
if (_additionalProperties!=null) {
_safeResolve=this._refHelper.safeResolve(_additionalProperties);
}
final Object apSchema = _safeResolve;
String _xifexpression = null;
if ((model.getProperties().isEmpty() && (apSchema == null))) {
_xifexpression = this.defaultRender(model, name, referrer, ind, det);
} else {
String _xblockexpression_1 = null;
{
String _xifexpression_1 = null;
if ((name != null)) {
_xifexpression_1 = this.defaultRender(model, name, referrer, ind, det);
}
final String modelRow = _xifexpression_1;
StringConcatenation _builder = new StringConcatenation();
_builder.append(modelRow);
{
Set> _entrySet = model.getProperties().entrySet();
for(final Map.Entry prop : _entrySet) {
Property _value = prop.getValue();
String _key = prop.getKey();
String _plus = ("!" + _key);
String _renderObject = this.renderObject(_value, _plus, model, ind.advance2());
_builder.append(_renderObject);
}
}
_builder.newLineIfNotEmpty();
String _renderObject_1 = null;
if (apSchema!=null) {
_renderObject_1=this.renderObject(apSchema, "![additional properties]", model, ind.advance2());
}
_builder.append(_renderObject_1);
_builder.newLineIfNotEmpty();
_xblockexpression_1 = _builder.toString();
}
_xifexpression = _xblockexpression_1;
}
_xblockexpression = _xifexpression;
}
return _xblockexpression;
}
private String _getTypeSpec(final ModelImpl model, final AttrDetails det) {
String _xifexpression = null;
boolean _isEmpty = model.getProperties().isEmpty();
if (_isEmpty) {
final String modelType = this.getDefaultTypeSpec(model, det);
String _xifexpression_1 = null;
boolean _isEmpty_1 = modelType.isEmpty();
boolean _not = (!_isEmpty_1);
if (_not) {
_xifexpression_1 = (modelType + ": ");
}
String _type = model.getType();
final String namedType = (_xifexpression_1 + _type);
StringConcatenation _builder = new StringConcatenation();
_builder.append(namedType);
CharSequence _infoButton = det.getInfoButton();
_builder.append(_infoButton);
return _builder.toString();
} else {
_xifexpression = this.getDefaultTypeSpec(model, det);
}
return _xifexpression;
}
/**
* ArrayModel covers array schemas
*/
private String _render(final ArrayModel model, final String name, final Object referrer, final Indentation ind, final AttrDetails det) {
String _xblockexpression = null;
{
det.setObject(this._arrayHelper.getElementType(model));
StringConcatenation _builder = new StringConcatenation();
String _defaultRender = this.defaultRender(model, name, referrer, ind, det);
_builder.append(_defaultRender);
_builder.newLineIfNotEmpty();
String _renderObject = this.renderObject(this._arrayHelper.getElementType(model), null, null, ind.advance2());
_builder.append(_renderObject);
_builder.newLineIfNotEmpty();
_xblockexpression = _builder.toString();
}
return _xblockexpression;
}
private String _getTypeSpec(final ArrayModel model, final AttrDetails det) {
StringConcatenation _builder = new StringConcatenation();
String _arrayTypeSpec = this._arrayHelper.getArrayTypeSpec(model);
_builder.append(_arrayTypeSpec);
CharSequence _infoButton = det.getInfoButton();
_builder.append(_infoButton);
return _builder.toString();
}
/**
* ComposedModel covers allOf schemas
*/
private String _render(final ComposedModel model, final String name, final Object referrer, final Indentation ind, final AttrDetails det) {
String _xblockexpression = null;
{
ind.use2();
final Indentation componentInd = ind.advance2();
StringConcatenation _builder = new StringConcatenation();
String _defaultRender = this.defaultRender(model, name, referrer, ind, det);
_builder.append(_defaultRender);
_builder.newLineIfNotEmpty();
{
List _allOf = model.getAllOf();
for(final Model member : _allOf) {
String _renderMemberModel = this.renderMemberModel(this._refHelper.safeResolve(member), componentInd, det);
_builder.append(_renderMemberModel);
}
}
_builder.newLineIfNotEmpty();
_xblockexpression = _builder.toString();
}
return _xblockexpression;
}
private String renderMemberModel(final Object member, final Indentation ind, final AttrDetails det) {
String _xblockexpression = null;
{
final Model memberModel = ((Model) member);
if ((memberModel instanceof ModelImpl)) {
ModelImpl mi = ((ModelImpl) memberModel);
if (((Objects.equal(mi.getType(), "object") && mi.getProperties().isEmpty()) && (mi.getAdditionalProperties() == null))) {
return null;
}
}
StringConcatenation _builder = new StringConcatenation();
String _renderMemberRow = this.renderMemberRow(memberModel, ind.copy(), det);
_builder.append(_renderMemberRow);
_builder.newLineIfNotEmpty();
String _renderObject = this.renderObject(memberModel, null, null, ind.copy());
_builder.append(_renderObject);
_builder.newLineIfNotEmpty();
_xblockexpression = _builder.toString();
}
return _xblockexpression;
}
private String renderMemberRow(final Model member, final Indentation ind, final AttrDetails det) {
String _xifexpression = null;
Boolean _isShowComponentModels = this._optionHelper.isShowComponentModels();
if ((_isShowComponentModels).booleanValue()) {
String _xblockexpression = null;
{
StringConcatenation _builder = new StringConcatenation();
_builder.append("component model: ");
String _typeSpec = this.getTypeSpec(member, det);
String _htmlEscape = null;
if (_typeSpec!=null) {
_htmlEscape=this._htmlHelper.htmlEscape(_typeSpec);
}
String _samp = null;
if (_htmlEscape!=null) {
_samp=this._htmlHelper.getSamp(_htmlEscape);
}
_builder.append(_samp);
_builder.append("");
final String text = _builder.toString();
String _indentTextToCode = this.indentTextToCode(text.toString(), ind);
_xblockexpression = this.wrapHeaderRow(Collections.unmodifiableList(CollectionLiterals.newArrayList(_indentTextToCode)));
}
_xifexpression = _xblockexpression;
}
return _xifexpression;
}
/**
* ObjectProperty
*/
private String _render(final ObjectProperty prop, final String name, final Object referrer, final Indentation ind, final AttrDetails det) {
StringConcatenation _builder = new StringConcatenation();
{
if (((name != null) && (!name.isEmpty()))) {
String _defaultRender = this.defaultRender(prop, name, referrer, ind, det);
_builder.append(_defaultRender);
}
}
_builder.newLineIfNotEmpty();
{
Set> _entrySet = prop.getProperties().entrySet();
for(final Map.Entry field : _entrySet) {
Property _value = field.getValue();
String _key = field.getKey();
String _plus = ("!" + _key);
String _renderObject = this.renderObject(_value, _plus, prop, ind.advance2());
_builder.append(_renderObject);
}
}
_builder.newLineIfNotEmpty();
return _builder.toString();
}
/**
* ArrayProperty
*/
private String _render(final ArrayProperty prop, final String name, final Object referrer, final Indentation ind, final AttrDetails det) {
String _xblockexpression = null;
{
det.setObject(this._arrayHelper.getElementType(prop));
StringConcatenation _builder = new StringConcatenation();
String _defaultRender = this.defaultRender(prop, name, referrer, ind, det);
_builder.append(_defaultRender);
_builder.newLineIfNotEmpty();
String _renderObject = this.renderObject(this._arrayHelper.getElementType(prop), null, null, ind.advance2());
_builder.append(_renderObject);
_builder.newLineIfNotEmpty();
_xblockexpression = _builder.toString();
}
return _xblockexpression;
}
private String _getTypeSpec(final ArrayProperty prop, final AttrDetails det) {
StringConcatenation _builder = new StringConcatenation();
String _arrayTypeSpec = this._arrayHelper.getArrayTypeSpec(prop);
_builder.append(_arrayTypeSpec);
CharSequence _infoButton = det.getInfoButton();
_builder.append(_infoButton);
return _builder.toString();
}
/**
* MapProperty
*/
private String _render(final MapProperty prop, final String name, final Object referrer, final Indentation ind, final AttrDetails det) {
String _xblockexpression = null;
{
Property _additionalProperties = prop.getAdditionalProperties();
Object _safeResolve = null;
if (_additionalProperties!=null) {
_safeResolve=this._refHelper.safeResolve(_additionalProperties);
}
final Object apSchema = _safeResolve;
StringConcatenation _builder = new StringConcatenation();
String _defaultRender = this.defaultRender(prop, name, referrer, ind, det);
_builder.append(_defaultRender);
_builder.newLineIfNotEmpty();
String _renderObject = null;
if (apSchema!=null) {
_renderObject=this.renderObject(apSchema, "![additional properties]", referrer, ind.advance2());
}
_builder.append(_renderObject);
_builder.newLineIfNotEmpty();
_xblockexpression = _builder.toString();
}
return _xblockexpression;
}
/**
* All other property types (properties with primitive types)
*/
private String _render(final AbstractProperty prop, final String name, final Object referrer, final Indentation ind, final AttrDetails det) {
StringConcatenation _builder = new StringConcatenation();
{
if ((name != null)) {
String _defaultRender = this.defaultRender(prop, name, referrer, ind, det);
_builder.append(_defaultRender);
}
}
_builder.newLineIfNotEmpty();
return _builder.toString();
}
private String _getTypeSpec(final AbstractProperty prop, final AttrDetails det) {
StringConcatenation _builder = new StringConcatenation();
String _defaultTypeSpec = this.getDefaultTypeSpec(prop, det);
_builder.append(_defaultTypeSpec);
CharSequence _infoButton = det.getInfoButton();
_builder.append(_infoButton);
return _builder.toString();
}
/**
* List - list of operation parameters
*/
private String _render(final List params, final String name, final Object referrer, final Indentation ind, final AttrDetails det) {
String _xifexpression = null;
boolean _isEmpty = params.isEmpty();
boolean _not = (!_isEmpty);
if (_not) {
StringConcatenation _builder = new StringConcatenation();
{
for(final Parameter param : params) {
String _renderObject = this.renderObject(param, null, referrer, ind.advance2());
_builder.append(_renderObject);
}
}
_xifexpression = _builder.toString();
}
return _xifexpression;
}
/**
* SerializableParameter
*/
private String _render(final SerializableParameter param, final String name, final Object referrer, final Indentation ind, final AttrDetails det) {
String _xblockexpression = null;
{
Object _xifexpression = null;
String _type = param.getType();
boolean _equals = Objects.equal(_type, "array");
if (_equals) {
_xifexpression = this._arrayHelper.getElementType(param);
} else {
_xifexpression = param;
}
final Object detailType = _xifexpression;
det.setObject(detailType);
StringConcatenation _builder = new StringConcatenation();
String _defaultRender = this.defaultRender(param, name, referrer, ind, det);
_builder.append(_defaultRender);
_builder.newLineIfNotEmpty();
_xblockexpression = _builder.toString();
}
return _xblockexpression;
}
private String _chooseName(final SerializableParameter param, final String offeredName) {
return param.getName();
}
private String _getTypeSpec(final SerializableParameter param, final AttrDetails det) {
String _xifexpression = null;
String _type = param.getType();
boolean _equals = Objects.equal(_type, "array");
if (_equals) {
StringConcatenation _builder = new StringConcatenation();
String _arrayTypeSpec = this._arrayHelper.getArrayTypeSpec(param);
_builder.append(_arrayTypeSpec);
CharSequence _infoButton = det.getInfoButton();
_builder.append(_infoButton);
_xifexpression = _builder.toString();
} else {
StringConcatenation _builder_1 = new StringConcatenation();
String _defaultTypeSpec = this.getDefaultTypeSpec(param, det);
_builder_1.append(_defaultTypeSpec);
CharSequence _infoButton_1 = det.getInfoButton();
_builder_1.append(_infoButton_1);
_xifexpression = _builder_1.toString();
}
return _xifexpression;
}
/**
* Unresolvable Ref
*/
private String _chooseName(final BadReferenceException e, final String offeredName) {
String _xifexpression = null;
if (((offeredName != null) && offeredName.startsWith("!"))) {
_xifexpression = offeredName.substring(1);
} else {
_xifexpression = offeredName;
}
return _xifexpression;
}
private String _getTypeSpec(final BadReferenceException e, final AttrDetails det) {
return "ref";
}
private String _getDoc(final BadReferenceException e) {
String _xblockexpression = null;
{
final String refString = e.getRefString().replaceAll("#/_UNRESOLVABLE/", "");
StringConcatenation _builder = new StringConcatenation();
_builder.append("Invalid Reference: ");
String _htmlEscape = this._htmlHelper.htmlEscape(refString);
_builder.append(_htmlEscape);
_builder.append("
");
_xblockexpression = _builder.toString();
}
return _xblockexpression;
}
/**
* Recursive rendering attempt
*/
private String _renderColumn(final RecursiveRenderException e, final String colAttr, final String name, final Object referrer, final Indentation ind, final AttrDetails det) {
String _xblockexpression = null;
{
final Object obj = this._refHelper.safeResolve(e.getObject());
String _switchResult = null;
if (colAttr != null) {
switch (colAttr) {
case "name":
String _xblockexpression_1 = null;
{
final String tooltip = " …";
String _htmlEscape = this._htmlHelper.htmlEscape(this.chooseName(obj, name));
_xblockexpression_1 = this.indentCode((_htmlEscape + tooltip), ind);
}
_switchResult = _xblockexpression_1;
break;
case "type":
String _typeSpec = this.getTypeSpec(obj, det);
String _code = null;
if (_typeSpec!=null) {
_code=this._htmlHelper.getCode(_typeSpec);
}
_switchResult = _code;
break;
default:
_switchResult = this.getValueForDisplay(this._attributeHelper.getAttribute(obj, colAttr));
break;
}
} else {
_switchResult = this.getValueForDisplay(this._attributeHelper.getAttribute(obj, colAttr));
}
_xblockexpression = _switchResult;
}
return _xblockexpression;
}
/**
* Attempt to render nonsensical array
*/
private String _getTypeSpec(final BadArrayException e, final AttrDetails det) {
return "???[]";
}
private String _getDoc(final BadArrayException e) {
return e.getMessage();
}
/**
* Utility methods
*/
private String wrapRow(final String value, final boolean noBorder) {
return this.wrapRow(Collections.unmodifiableList(CollectionLiterals.newArrayList(value)), noBorder);
}
private String wrapRow(final List values) {
return this.wrapRow(values, false);
}
private String wrapRow(final List values, final boolean noBorder) {
String _xblockexpression = null;
{
String _xifexpression = null;
if (noBorder) {
_xifexpression = " style=\"border-top:0px\"";
}
final String style = _xifexpression;
StringConcatenation _builder = new StringConcatenation();
_builder.append("");
{
for(final String value : values) {
_builder.append("");
_builder.append(value);
_builder.append(" ");
}
}
_builder.append(" ");
_xblockexpression = _builder.toString();
}
return _xblockexpression;
}
private String wrapHeaderRow(final List values) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("");
{
for(final String value : values) {
_builder.append("");
_builder.append(value);
_builder.append(" ");
}
}
_builder.append(" ");
return _builder.toString();
}
public CharSequence getColSpan(final List values) {
CharSequence _xifexpression = null;
if (((values.size() == 1) && (((List)Conversions.doWrapArray(this.cols)).size() > 1))) {
StringConcatenation _builder = new StringConcatenation();
_builder.append(" ");
_builder.append("colspan=\"");
int _size = ((List)Conversions.doWrapArray(this.cols)).size();
_builder.append(_size, " ");
_builder.append("\"");
_xifexpression = _builder;
}
return _xifexpression;
}
private String indentTextToCode(final String s, final Indentation ind) {
String _xblockexpression = null;
{
ind.use1();
int _n1 = ind.getN1();
int _n2 = ind.getN2();
int _plus = (_n1 + _n2);
String _samp = this._htmlHelper.getSamp(this.getIndentation(_plus));
_xblockexpression = (_samp + s);
}
return _xblockexpression;
}
private String indentCode(final String s, final Indentation ind) {
String _xblockexpression = null;
{
ind.use1();
ind.use2();
String _samp = this._htmlHelper.getSamp(this.getIndentation(ind.getN1()));
String _indentation = this.getIndentation(ind.getN2());
String _code = this._htmlHelper.getCode((_indentation + s));
_xblockexpression = (_samp + _code);
}
return _xblockexpression;
}
private String getIndentation(final int n) {
return StringUtils.repeat(" ", n);
}
private String getValueForDisplay(final Object o) {
String _formatValue = null;
if (o!=null) {
_formatValue=this.formatValue(o);
}
return _formatValue;
}
private String _formatValue(final String s) {
String _htmlEscape = null;
if (s!=null) {
_htmlEscape=this._htmlHelper.htmlEscape(s);
}
return _htmlEscape;
}
private String _formatValue(final List> list) {
StringConcatenation _builder = new StringConcatenation();
{
boolean _hasElements = false;
for(final Object item : list) {
if (!_hasElements) {
_hasElements = true;
} else {
_builder.appendImmediate("
", "");
}
_builder.append("item?.toString?.htmlEscape");
}
}
return _builder.toString();
}
private String render(final Object model, final String name, final Object referrer, final Indentation ind, final AttrDetails det) {
if (model instanceof ArrayModel) {
return _render((ArrayModel)model, name, referrer, ind, det);
} else if (model instanceof ComposedModel) {
return _render((ComposedModel)model, name, referrer, ind, det);
} else if (model instanceof ModelImpl) {
return _render((ModelImpl)model, name, referrer, ind, det);
} else if (model instanceof ArrayProperty) {
return _render((ArrayProperty)model, name, referrer, ind, det);
} else if (model instanceof MapProperty) {
return _render((MapProperty)model, name, referrer, ind, det);
} else if (model instanceof ObjectProperty) {
return _render((ObjectProperty)model, name, referrer, ind, det);
} else if (model instanceof List) {
return _render((List)model, name, referrer, ind, det);
} else if (model instanceof SerializableParameter) {
return _render((SerializableParameter)model, name, referrer, ind, det);
} else if (model instanceof AbstractProperty) {
return _render((AbstractProperty)model, name, referrer, ind, det);
} else if (model != null) {
return _render(model, name, referrer, ind, det);
} else {
throw new IllegalArgumentException("Unhandled parameter types: " +
Arrays.
© 2015 - 2025 Weber Informatics LLC | Privacy Policy