Package org.dcm4che3.conf.api.generic

Examples of org.dcm4che3.conf.api.generic.ConfigField


    public static void main(String[] args) throws Exception {
        LdapDicomConfiguration dicomConf = new LdapDicomConfiguration();
        Device device = dicomConf.findDevice(args[0]);
        Main main = new Main();
        main.bind("dicomDevice", new DicomDeviceComponent(device));
        main.addRouteBuilder(new RouteBuilder(){

            @Override
            public void configure() throws Exception {
                from("dicomDevice:dicom?sopClasses=1.2.840.10008.1.1").bean(EchoSCP.class);
View Full Code Here


                return null;
        }

        @Override
        public void write(Object serialized, ReflectiveConfig config, ConfigWriter writer, Field field) throws ConfigurationException {
            ConfigField fieldAnno = field.getAnnotation(ConfigField.class);
            writer.storeNotEmpty(fieldAnno.name(), serialized);
        }
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    @Override
    public Map<String,Object> read(ReflectiveConfig config, ConfigReader reader, Field field) throws ConfigurationException {
        ConfigField fieldAnno = field.getAnnotation(ConfigField.class);

        Map<String,Object> cnode = new HashMap<String,Object>();

        // read collection
        ConfigReader collectionReader = reader.getChildReader(getCollectionName(fieldAnno));
        Map<String, ConfigReader> map = collectionReader.readCollection(fieldAnno.mapKey());

        ConfigTypeAdapter<V, Object> valueAdapter = (ConfigTypeAdapter<V, Object>) getValueAdapter(field, config);

        // for each element, read it using the value adapter
        for (Entry<String, ConfigReader> e : map.entrySet()) {
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    @Override
    public void write(Map<String,Object> serialized, ReflectiveConfig config, ConfigWriter writer, Field field) throws ConfigurationException {
        ConfigField fieldAnno = field.getAnnotation(ConfigField.class);

        // getValueAdapter
        ConfigTypeAdapter<V, Object> valueAdapter = (ConfigTypeAdapter<V, Object>) getValueAdapter(field, config);

        ConfigWriter collectionWriter = writer.createCollectionChild(getCollectionName(fieldAnno), field);

        if (serialized == null) return;
       
        for (Entry<String, Object> e : serialized.entrySet()) {

            ConfigWriter elementWriter = collectionWriter.getCollectionElementWriter(fieldAnno.mapKey(), e.getKey(), field);
            valueAdapter.write(e.getValue(), config, elementWriter, field);
            elementWriter.flushWriter();
        }
    }
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    @Override
    public void merge(Map<K, V> prev, Map<K, V> curr, ReflectiveConfig config, ConfigWriter diffwriter, Field field) throws ConfigurationException {
        ConfigField fieldAnno = field.getAnnotation(ConfigField.class);

        ConfigTypeAdapter<V, Object> valueAdapter = (ConfigTypeAdapter<V, Object>) getValueAdapter(field, config);
        ConfigTypeAdapter<K, String> keyAdapter = (ConfigTypeAdapter<K, String>) getKeyAdapter(field, config);

        ConfigWriter collectionWriter = diffwriter.getChildWriter(getCollectionName(fieldAnno), field);

        // remove nodes that were deleted since prev
        for (Entry<K, V> e : prev.entrySet())
            if (curr.get(e.getKey()) == null)
                collectionWriter.removeCollectionElement(fieldAnno.mapKey(), keyAdapter.serialize(e.getKey(), config, null));

        // add new nodes and merge existing
        for (Entry<K, V> e : curr.entrySet()) {

            // serialize key
            String serializedKey = keyAdapter.serialize(e.getKey(), config, null);
            // if new node
            if (prev.get(e.getKey()) == null) {
                ConfigWriter elementWriter = collectionWriter.getCollectionElementWriter(fieldAnno.mapKey(), serializedKey, field);
                // serialize
                Object serialized = valueAdapter.serialize(e.getValue(), config, field);
                valueAdapter.write(serialized, config, elementWriter, field);
                elementWriter.flushWriter();
            }
            // existing node
            else {
                ConfigWriter elementWriter = collectionWriter.getCollectionElementDiffWriter(fieldAnno.mapKey(), serializedKey);
                valueAdapter.merge(prev.get(e.getKey()), e.getValue(), config, elementWriter, field);
                elementWriter.flushDiffs();
            }
        }
    }
View Full Code Here

        }
    }
   
    @Override
    public Map<String, Object> getMetadata(ReflectiveConfig config, Field field) throws ConfigurationException {
        ConfigField fieldAnno = field.getAnnotation(ConfigField.class);

        Map<String, Object> metadata =  new HashMap<String, Object>();
        Map<String, Object> keyMetadata =  new HashMap<String, Object>();
        Map<String, Object> valueMetadata =  new HashMap<String, Object>();
       
View Full Code Here

*/
public class SetTypeAdapter<T> implements ConfigTypeAdapter<Set<T>, List<String>> {

    @Override
    public void write(List<String> serialized, ReflectiveConfig config, ConfigWriter writer, Field field) throws ConfigurationException {
        ConfigField fieldAnno = field.getAnnotation(ConfigField.class);
        writer.storeNotEmpty(fieldAnno.name(), serialized.toArray(new String[serialized.size()]));
    }
View Full Code Here

        return serialized;
    }

    @Override
    public List<String> read(ReflectiveConfig config, ConfigReader reader, Field field) throws ConfigurationException {
        ConfigField fieldAnno = field.getAnnotation(ConfigField.class);
        return Arrays.asList(reader.asStringArray(fieldAnno.name()));
    }
View Full Code Here

    }

    @Override
    public void merge(Set<T> prev, Set<T> curr, ReflectiveConfig config, ConfigWriter diffwriter, Field field) throws ConfigurationException {
        // regular merge
        ConfigField fieldAnno = field.getAnnotation(ConfigField.class);

        String[] prevSerialized = serialize(prev, config, field).toArray(new String[0]);
        String[] currSerialized = serialize(curr, config, field).toArray(new String[0]);

        diffwriter.storeDiff(fieldAnno.name(), prevSerialized, currSerialized);
    }
View Full Code Here

            return;
        }
       
        // if this object is a property, create a child
        if (field != null && field.getType().equals(clazz)) {
            ConfigField fieldAnno = (ConfigField) field.getAnnotation(ConfigField.class);
            writer = writer.getChildWriter(fieldAnno.name(), field);
        }

        for (Field classField : clazz.getDeclaredFields()) {

            // if field is not annotated, skip it
            ConfigField fieldAnno = (ConfigField) classField.getAnnotation(ConfigField.class);
            if (fieldAnno == null)
                continue;

            // find typeadapter
            ConfigTypeAdapter customRep = config.lookupTypeAdapter(classField.getType());

            if (customRep != null) {

                // this is done in the next phase after flush
                if (!customRep.isWritingChildren(classField))
                    customRep.write(serialized.get(fieldAnno.name()), config, writer, classField);
            } else {
                throw new ConfigurationException("Corresponding 'writer' was not found for field" + fieldAnno.name());
            }
        }

        // do actual store
        writer.flushWriter();

        // now when we have a node generated, store children
        for (Field classField : clazz.getDeclaredFields()) {

            // if field is not annotated, skip it
            ConfigField fieldAnno = (ConfigField) classField.getAnnotation(ConfigField.class);
            if (fieldAnno == null)
                continue;

            // find typeadapter
            ConfigTypeAdapter customRep = config.lookupTypeAdapter(classField.getType());

            if (customRep.isWritingChildren(classField))
                customRep.write(serialized.get(fieldAnno.name()), config, writer, classField);

        }

    }
View Full Code Here

TOP

Related Classes of org.dcm4che3.conf.api.generic.ConfigField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.