Search in sources :

Example 1 with MapEx

use of com.revolsys.collection.map.MapEx in project com.revolsys.open by revolsys.

the class MultiStopLinearGradient method toMap.

@Override
public MapEx toMap() {
    final MapEx map = newTypeMap("multiStopLinearGradient");
    addToMap(map, "stops", this.stops);
    return map;
}
Also used : MapEx(com.revolsys.collection.map.MapEx)

Example 2 with MapEx

use of com.revolsys.collection.map.MapEx in project com.revolsys.open by revolsys.

the class Edge method getProperties.

@Override
public MapEx getProperties() {
    if (this.graph == null) {
        return MapEx.EMPTY;
    } else {
        final Map<Integer, MapEx> propertiesById = this.graph.getEdgePropertiesById();
        MapEx properties = propertiesById.get(this.id);
        if (properties == null) {
            properties = new LinkedHashMapEx();
            propertiesById.put(this.id, properties);
        }
        return properties;
    }
}
Also used : MapEx(com.revolsys.collection.map.MapEx) LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx) LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx)

Example 3 with MapEx

use of com.revolsys.collection.map.MapEx in project com.revolsys.open by revolsys.

the class JdbcUtils method readMap.

public static MapEx readMap(final ResultSet rs) throws SQLException {
    final MapEx values = new LinkedHashMapEx();
    final ResultSetMetaData metaData = rs.getMetaData();
    for (int i = 1; i <= metaData.getColumnCount(); i++) {
        final String name = metaData.getColumnName(i);
        final Object value = rs.getObject(i);
        values.put(name, value);
    }
    return values;
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) MapEx(com.revolsys.collection.map.MapEx) LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx) LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx)

Example 4 with MapEx

use of com.revolsys.collection.map.MapEx in project com.revolsys.open by revolsys.

the class MapSerializer method writeToFile.

default void writeToFile(final Object target) {
    if (target != null) {
        final MapEx map = toMap();
        Json.writeMap(map, target, true);
    }
}
Also used : LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx) MapEx(com.revolsys.collection.map.MapEx)

Example 5 with MapEx

use of com.revolsys.collection.map.MapEx in project com.revolsys.open by revolsys.

the class MapSerializer method toMapValue.

@SuppressWarnings("rawtypes")
default Object toMapValue(final Object value) {
    if (value == null) {
        return null;
    } else {
        if (value instanceof MapSerializer) {
            final MapSerializer mapSerializer = (MapSerializer) value;
            final Map<String, Object> mapObject = mapSerializer.toMap();
            if (mapObject == null || mapObject.isEmpty()) {
                return null;
            }
            return mapObject;
        } else if (value instanceof Map) {
            final Map<String, Object> mapObject = (Map<String, Object>) value;
            if (mapObject.isEmpty()) {
                return null;
            }
            final MapEx map = new LinkedHashMapEx();
            for (final Entry<String, Object> entry : mapObject.entrySet()) {
                final CharSequence name = entry.getKey();
                final Object object = entry.getValue();
                addToMap(map, name, object);
            }
            return map;
        } else if (value instanceof Collection) {
            final Collection collectionObject = (Collection) value;
            if (collectionObject.isEmpty()) {
                return null;
            }
            final List<Object> list = new ArrayList<>();
            for (final Object object : collectionObject) {
                final Object listValue = toMapValue(object);
                list.add(listValue);
            }
            return list;
        } else if (value instanceof Boolean) {
            return value;
        } else if (value instanceof Number) {
            return value;
        } else if (value instanceof String) {
            final String string = (String) value;
            if (Property.hasValue(string)) {
                return string.trim();
            } else {
                return null;
            }
        } else if (value.getClass().isArray()) {
            return Lists.arrayToList(value);
        } else if (value instanceof Component) {
            return null;
        } else {
            final String string = DataTypes.toString(value);
            if (Property.hasValue(string)) {
                return string.trim();
            } else {
                return null;
            }
        }
    }
}
Also used : LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx) MapEx(com.revolsys.collection.map.MapEx) ArrayList(java.util.ArrayList) Entry(java.util.Map.Entry) Collection(java.util.Collection) LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx) Component(java.awt.Component) Map(java.util.Map)

Aggregations

MapEx (com.revolsys.collection.map.MapEx)144 LinkedHashMapEx (com.revolsys.collection.map.LinkedHashMapEx)48 ArrayList (java.util.ArrayList)17 Resource (com.revolsys.spring.resource.Resource)9 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)7 Map (java.util.Map)7 HashMap (java.util.HashMap)6 PathName (com.revolsys.io.PathName)5 UrlResource (com.revolsys.spring.resource.UrlResource)5 DataType (com.revolsys.datatype.DataType)4 FieldDefinition (com.revolsys.record.schema.FieldDefinition)4 PathResource (com.revolsys.spring.resource.PathResource)4 Color (java.awt.Color)4 LinkedHashMap (java.util.LinkedHashMap)4 List (java.util.List)4 TreeMap (java.util.TreeMap)4 NamedLinkedHashMapEx (com.revolsys.collection.map.NamedLinkedHashMapEx)3 Geometry (com.revolsys.geometry.model.Geometry)3 LineString (com.revolsys.geometry.model.LineString)3 Record (com.revolsys.record.Record)3