public TemplateModel create(Object object, ObjectWrapper wrapper) { return new CollectionModel((Collection) object, (BeansWrapper) wrapper); } };
private static boolean isBuggySeqButGoodCollection( TemplateModel model) { return model instanceof CollectionModel ? !((CollectionModel) model).getSupportsIndexedAccess() : false; }
/** * Retrieves the i-th object from the collection, wrapped as a TemplateModel. * @throws TemplateModelException if the index is out of bounds, or the * underlying collection is not a List. */ public TemplateModel get(int index) throws TemplateModelException { // Don't forget to keep getSupportsIndexedAccess in sync with this! if (object instanceof List) { try { return wrap(((List) object).get(index)); } catch (IndexOutOfBoundsException e) { return null; // throw new TemplateModelException("Index out of bounds: " + index); } } else { throw new TemplateModelException("Underlying collection is not a list, it's " + object.getClass().getName()); } }
@Override public String getAsString() { return UtilCodec.getEncoder("html").encode(super.getAsString()); }
@SuppressWarnings("unchecked") public CollectionModel createTemplateFeatureCollection( FeatureCollection collection, BeansWrapper wrapper) { return new CollectionModel(DataUtilities.list(collection), wrapper); } }
private static boolean isBuggySeqButGoodCollection( TemplateModel model) { return model instanceof CollectionModel ? !((CollectionModel) model).getSupportsIndexedAccess() : false; }
/** * Retrieves the i-th object from the collection, wrapped as a TemplateModel. * @throws TemplateModelException if the index is out of bounds, or the * underlying collection is not a List. */ public TemplateModel get(int index) throws TemplateModelException { // Don't forget to keep getSupportsIndexedAccess in sync with this! if (object instanceof List) { try { return wrap(((List) object).get(index)); } catch (IndexOutOfBoundsException e) { return null; // throw new TemplateModelException("Index out of bounds: " + index); } } else { throw new TemplateModelException("Underlying collection is not a list, it's " + object.getClass().getName()); } }
public TemplateModel create(Object object, ObjectWrapper wrapper) { return new CollectionModel((Collection)object, (BeansWrapper)wrapper); } };
private static boolean isBuggySeqButGoodCollection( TemplateModel model) { return model instanceof CollectionModel ? !((CollectionModel) model).getSupportsIndexedAccess() : false; }
/** * Retrieves the i-th object from the collection, wrapped as a TemplateModel. * @throws TemplateModelException if the index is out of bounds, or the * underlying collection is not a List. */ public TemplateModel get(int index) throws TemplateModelException { // Don't forget to keep getSupportsIndexedAccess in sync with this! if (object instanceof List) { try { return wrap(((List) object).get(index)); } catch (IndexOutOfBoundsException e) { return null; // throw new TemplateModelException("Index out of bounds: " + index); } } else { throw new TemplateModelException("Underlying collection is not a list, it's " + object.getClass().getName()); } }
var CollectionModel = Backbone.Model.extend({ urlRoot: "collection/endpoint/" }); var myModel = new CollectionModel(); // ...sometime later... myModel.save({ arrayAttribute: yourCollection.toJSON() }, { patch: true });
private static boolean isBuggySeqButGoodCollection( TemplateModel model) { return model instanceof CollectionModel ? !((CollectionModel) model).getSupportsIndexedAccess() : false; }
/** * Retrieves the i-th object from the collection, wrapped as a TemplateModel. * @throws TemplateModelException if the index is out of bounds, or the * underlying collection is not a List. */ public TemplateModel get(int index) throws TemplateModelException { // Don't forget to keep getSupportsIndexedAccess in sync with this! if (object instanceof List) { try { return wrap(((List)object).get(index)); } catch(IndexOutOfBoundsException e) { return null; // throw new TemplateModelException("Index out of bounds: " + index); } } else { throw new TemplateModelException("Underlying collection is not a list, it's " + object.getClass().getName()); } }
public TemplateModel create(Object object, ObjectWrapper wrapper) { return new CollectionModel((Collection) object, (BeansWrapper) wrapper); } };
if (valueToDump instanceof CollectionModel && ! ((CollectionModel)valueToDump).getSupportsIndexedAccess()) { map.putAll( getTemplateModelDump( (TemplateCollectionModel)valueToDump ) ); } else {
public TemplateModel create(Object object, ObjectWrapper wrapper) { return new CollectionModel((Collection) object, (BeansWrapper) wrapper); } };
@Override protected void wrapInternal(Map properties, SimpleHash model, NamespaceInfo object) { List<ResourceInfo> stores = catalog.getResourcesByNamespace(object, ResourceInfo.class); properties.put( "resources", new CollectionModel( stores, new ObjectToMapWrapper(ResourceInfo.class) ) ); properties.put( "isDefault", object.equals( catalog.getDefaultNamespace() ) ); } });
@Override protected void wrapInternal(Map properties, SimpleHash model, DataStoreInfo object) { List<FeatureTypeInfo> featureTypes = catalog.getFeatureTypesByDataStore(object); properties.put( "featureTypes", new CollectionModel( featureTypes, new ObjectToMapWrapper(FeatureTypeInfo.class) ) ); } });
@Override protected void wrapInternal(Map properties, SimpleHash model, WorkspaceInfo object) { List<DataStoreInfo> dataStores = catalog.getStoresByWorkspace(object, DataStoreInfo.class); properties.put( "dataStores", new CollectionModel( dataStores, new ObjectToMapWrapper(DataStoreInfo.class) ) ); List<CoverageStoreInfo> coverageStores = catalog.getStoresByWorkspace(object, CoverageStoreInfo.class); properties.put( "coverageStores", new CollectionModel( coverageStores, new ObjectToMapWrapper(CoverageStoreInfo.class) ) ); List<WMSStoreInfo> wmsStores = catalog.getStoresByWorkspace(object, WMSStoreInfo.class); properties.put( "wmsStores", new CollectionModel( wmsStores, new ObjectToMapWrapper(WMSStoreInfo.class) ) ); properties.put( "isDefault", object.equals( catalog.getDefaultWorkspace() ) ); } });
@Override protected void wrapInternal(Map properties, SimpleHash model, WMSStoreInfo object) { List<WMSLayerInfo> wmsLayers = catalog.getResourcesByStore(object, WMSLayerInfo.class); properties.put( "wmsLayers", new CollectionModel( wmsLayers, new ObjectToMapWrapper(WMSLayerInfo.class) ) ); } });