Search in sources :

Example 16 with Member

use of org.geotoolkit.sml.xml.v100.Member in project eomcs-java by eomcs.

the class Exam0220 method main.

public static void main(String[] args) {
    // 1) 제네릭이 적용되지 않은 ObjectBox 클래스 이용
    ObjectBox b1 = new ObjectBox();
    ObjectBox b2 = new ObjectBox();
    ObjectBox b3 = new ObjectBox();
    ObjectBox b4 = new ObjectBox();
    // ObjectBox에 값 넣기
    b1.set(new Member("홍길동", 20));
    // new String("Hello").intern()
    b2.set("Hello");
    b3.set(new Date());
    // auto-boxing ==> b4.set(Integer.valueOf(100)) 문장으로 변경된다.
    b4.set(100);
    // 이렇게 ObjectBox에 다양한 타입의 값을 넣을 수 있는 이유?
    // => set()의 파라미터 타입은 Object 이기 때문이다.
    // => Object는 모든 자바 객체를 받을 수 있다.
    // 
    // ObjectBox 객체에서 값 꺼내기
    // => 값을 꺼낼 때마다 형변환 해야 한다.
    // 
    Member v1 = (Member) b1.get();
    System.out.println(v1);
    String v2 = (String) b2.get();
    System.out.println(v2);
    Date v3 = (Date) b3.get();
    System.out.println(v3);
    // auto-unboxing ==> ((Integer) b1.get()).intValue();
    int v4 = (int) b4.get();
    System.out.println(v4);
// ObjectBox 의 이점
// - 이전 방식에 비해 객체의 타입 별로 Box 클래스를 구분해서 쓰지 않으니 코딩이 편하다.
// - 이렇게 ObjectBox 클래스의 인스턴스 변수를 Object로 선언하니
// 다양한 객체를 보관할 수는 있다.
// 
// ObjectBox 의 단점
// - MemberBox나 StringBox, IntegerBox 처럼 특정 타입의 객체로 제한할 수 없다.
// - 또한 값을 꺼낼 때 원래의 타입으로 바꾸기 위해 형변환(type casting) 해야 하는 불편함이 있다.
// 그렇다고 이전처럼 각 타입 별로 Box 클래스를 정의하는 것은 바람직하지 않다.
// 
// 이런 문제점을 해결하기 위해 나온 문법이 "제네릭(Generic)"이다.
// 제네릭 문법을 이용하면 한 개의 클래스가 다양한 타입의 객체를 제한적으로 다룰 수 있다.
// 즉 각 타입 별로 클래스를 정의해야 하는 것을 한 개의 클래스로 만들 수 있다.
}
Also used : Member(com.eomcs.generic.ex02.Member) Date(java.util.Date)

Example 17 with Member

use of org.geotoolkit.sml.xml.v100.Member in project eomcs-java by eomcs.

the class Exam0230 method main.

public static void main(String[] args) {
    // 2) 제네릭이 적용된 Box 클래스 이용
    // - 먼저 Box가 어떤 타입의 값을 다룰 것인지 지정해야 한다.
    Box<Member> b1 = new Box<Member>();
    // - 인스턴스를 생성할 때 지정한 타입의 객체를 넘긴다.
    b1.set(new Member("홍길동", 20));
    // - 값을 꺼낼 때 형변환 할 필요가 없다.
    Member m = b1.get();
    System.out.println(m);
// - 제네릭에서 지정한 타입이 아닌 경우 컴파일 오류!
// b1.set(new String("Hello"));
// b1.set(100);
}
Also used : Member(com.eomcs.generic.ex02.Member)

Example 18 with Member

use of org.geotoolkit.sml.xml.v100.Member in project eomcs-java by eomcs.

the class Exam0240 method main.

public static void main(String[] args) {
    // 제네릭을 사용하면 한 개의 클래스를 가지고
    // 특정 타입만을 다루는 전용 객체를 만들 수 있다.
    Box<Member> b1 = new Box<>();
    Box<String> b2 = new Box<>();
    Box<Integer> b3 = new Box<>();
    b1.set(new Member("홍길동", 20));
    b2.set("Hello");
    b3.set(100);
    // 제네릭을 사용하면 get() 메서드가 각 타입별로 존재하는 것처럼 사용할 수 있다.
    // => 즉 형변환 할 필요가 없다.
    Member v1 = b1.get();
    String v2 = b2.get();
    Integer v3 = b3.get();
    System.out.println(v1);
    System.out.println(v2);
    System.out.println(v3);
}
Also used : Member(com.eomcs.generic.ex02.Member)

Example 19 with Member

use of org.geotoolkit.sml.xml.v100.Member in project geotoolkit by Geomatys.

the class SmlXMLFactory method convertTo101.

public static org.geotoolkit.sml.xml.v101.SensorML convertTo101(final org.geotoolkit.sml.xml.v100.SensorML sensor) {
    List<org.geotoolkit.sml.xml.v101.SensorML.Member> newMembers = new ArrayList<org.geotoolkit.sml.xml.v101.SensorML.Member>();
    for (Member oldMember : sensor.getMember()) {
        final org.geotoolkit.sml.xml.v101.AbstractProcessType newProcess;
        if (oldMember.getRealProcess() instanceof System) {
            newProcess = new org.geotoolkit.sml.xml.v101.SystemType();
        } else if (oldMember.getRealProcess() instanceof Component) {
            newProcess = new org.geotoolkit.sml.xml.v101.ComponentType();
        } else if (oldMember.getRealProcess() instanceof AbstractDataSource) {
            newProcess = new org.geotoolkit.sml.xml.v101.DataSourceType();
        } else if (oldMember.getRealProcess() instanceof AbstractProcessModel) {
            newProcess = new org.geotoolkit.sml.xml.v101.ProcessModelType();
        } else if (oldMember.getRealProcess() instanceof ComponentArray) {
            newProcess = new org.geotoolkit.sml.xml.v101.ComponentArrayType();
        } else {
            throw new IllegalArgumentException("Other sensor type than system, component, processModel, processChain, componentArray or datasource are not yet convertible");
        }
        AbstractProcessType oldProcess = (AbstractProcessType) oldMember.getRealProcess();
        // id
        newProcess.setId(oldProcess.getId());
        // name
        newProcess.setName(oldProcess.getName());
        // srsName
        newProcess.setSrsName(oldProcess.getSrsName());
        // description
        newProcess.setDescription(oldProcess.getDescription());
        // boundedBy
        newProcess.setBoundedBy(oldProcess.getBoundedBy());
        // capabilities
        List<org.geotoolkit.sml.xml.v101.Capabilities> newCapabilities = new ArrayList<org.geotoolkit.sml.xml.v101.Capabilities>();
        for (Capabilities oldCapa : oldProcess.getCapabilities()) {
            newCapabilities.add(new org.geotoolkit.sml.xml.v101.Capabilities(oldCapa));
        }
        newProcess.setCapabilities(newCapabilities);
        // characteristics
        List<org.geotoolkit.sml.xml.v101.Characteristics> newCharacteristics = new ArrayList<org.geotoolkit.sml.xml.v101.Characteristics>();
        for (Characteristics oldChar : oldProcess.getCharacteristics()) {
            newCharacteristics.add(new org.geotoolkit.sml.xml.v101.Characteristics(oldChar));
        }
        newProcess.setCharacteristics(newCharacteristics);
        // Classification
        List<org.geotoolkit.sml.xml.v101.Classification> newClassification = new ArrayList<org.geotoolkit.sml.xml.v101.Classification>();
        for (Classification oldClass : oldProcess.getClassification()) {
            newClassification.add(new org.geotoolkit.sml.xml.v101.Classification(oldClass));
        }
        newProcess.setClassification(newClassification);
        // Contact
        List<org.geotoolkit.sml.xml.v101.Contact> newContact = new ArrayList<org.geotoolkit.sml.xml.v101.Contact>();
        for (Contact oldContact : oldProcess.getContact()) {
            newContact.add(new org.geotoolkit.sml.xml.v101.Contact(oldContact));
        }
        newProcess.setContact(newContact);
        // Contact
        List<org.geotoolkit.sml.xml.v101.Documentation> newDocumentation = new ArrayList<org.geotoolkit.sml.xml.v101.Documentation>();
        for (Documentation oldDoc : oldProcess.getDocumentation()) {
            newDocumentation.add(new org.geotoolkit.sml.xml.v101.Documentation(oldDoc));
        }
        newProcess.setDocumentation(newDocumentation);
        // History
        List<org.geotoolkit.sml.xml.v101.History> newHistory = new ArrayList<org.geotoolkit.sml.xml.v101.History>();
        for (History oldhist : oldProcess.getHistory()) {
            newHistory.add(new org.geotoolkit.sml.xml.v101.History(oldhist));
        }
        newProcess.setHistory(newHistory);
        // Identification
        List<org.geotoolkit.sml.xml.v101.Identification> newIdentification = new ArrayList<org.geotoolkit.sml.xml.v101.Identification>();
        for (Identification oldIdent : oldProcess.getIdentification()) {
            newIdentification.add(new org.geotoolkit.sml.xml.v101.Identification(oldIdent));
        }
        newProcess.setIdentification(newIdentification);
        // keywords
        List<org.geotoolkit.sml.xml.v101.Keywords> newKeywords = new ArrayList<org.geotoolkit.sml.xml.v101.Keywords>();
        for (Keywords oldKeyw : oldProcess.getKeywords()) {
            newKeywords.add(new org.geotoolkit.sml.xml.v101.Keywords(oldKeyw));
        }
        newProcess.setKeywords(newKeywords);
        // legal constraint
        List<org.geotoolkit.sml.xml.v101.LegalConstraint> newLegalConstraints = new ArrayList<org.geotoolkit.sml.xml.v101.LegalConstraint>();
        for (LegalConstraint oldcons : oldProcess.getLegalConstraint()) {
            newLegalConstraints.add(new org.geotoolkit.sml.xml.v101.LegalConstraint(oldcons));
        }
        newProcess.setLegalConstraint(newLegalConstraints);
        // security constraint
        if (oldProcess.getSecurityConstraint() != null) {
            newProcess.setSecurityConstraint(new org.geotoolkit.sml.xml.v101.SecurityConstraint(oldProcess.getSecurityConstraint()));
        }
        // validTime
        if (oldProcess.getValidTime() != null) {
            newProcess.setValidTime(oldProcess.getValidTime());
        }
        if (oldProcess instanceof AbstractComponent) {
            AbstractComponent newAbsComponent = (AbstractComponent) newProcess;
            AbstractComponent oldAbsComponent = (AbstractComponent) oldProcess;
            // Inputs
            if (oldAbsComponent.getInputs() != null) {
                newAbsComponent.setInputs(oldAbsComponent.getInputs());
            }
            // outputs
            if (oldAbsComponent.getOutputs() != null) {
                newAbsComponent.setOutputs(oldAbsComponent.getOutputs());
            }
            // parameters
            if (oldAbsComponent.getParameters() != null) {
                newAbsComponent.setParameters(oldAbsComponent.getParameters());
            }
        }
        if (oldProcess instanceof AbstractDerivableComponent) {
            org.geotoolkit.sml.xml.v101.AbstractDerivableComponentType newDerComponent = (org.geotoolkit.sml.xml.v101.AbstractDerivableComponentType) newProcess;
            AbstractDerivableComponent oldDerComponent = (AbstractDerivableComponent) oldProcess;
            // Position
            if (oldDerComponent.getPosition() != null) {
                newDerComponent.setPosition(oldDerComponent.getPosition());
            }
            if (oldDerComponent.getSMLLocation() != null) {
                newDerComponent.setSMLLocation(oldDerComponent.getSMLLocation());
            }
            if (oldDerComponent.getInterfaces() != null) {
                newDerComponent.setInterfaces(new org.geotoolkit.sml.xml.v101.Interfaces(oldDerComponent.getInterfaces()));
            }
            if (oldDerComponent.getSpatialReferenceFrame() != null) {
                newDerComponent.setSpatialReferenceFrame(new org.geotoolkit.sml.xml.v101.SpatialReferenceFrame(oldDerComponent.getSpatialReferenceFrame()));
            }
            if (oldDerComponent.getTemporalReferenceFrame() != null) {
                newDerComponent.setTemporalReferenceFrame(new org.geotoolkit.sml.xml.v101.TemporalReferenceFrame(oldDerComponent.getTemporalReferenceFrame()));
            }
            if (oldDerComponent.getTimePosition() != null) {
                newDerComponent.setTimePosition(new org.geotoolkit.sml.xml.v101.TimePosition(oldDerComponent.getTimePosition()));
            }
        }
        if (oldProcess instanceof AbstractPureProcess) {
            org.geotoolkit.sml.xml.v101.AbstractPureProcessType newAbsPuProc = (org.geotoolkit.sml.xml.v101.AbstractPureProcessType) newProcess;
            AbstractPureProcess oldAbsPuProc = (AbstractPureProcess) oldProcess;
            // Inputs
            if (oldAbsPuProc.getInputs() != null) {
                newAbsPuProc.setInputs(new org.geotoolkit.sml.xml.v101.Inputs(oldAbsPuProc.getInputs()));
            }
            // outputs
            if (oldAbsPuProc.getOutputs() != null) {
                newAbsPuProc.setOutputs(new org.geotoolkit.sml.xml.v101.Outputs(oldAbsPuProc.getOutputs()));
            }
            // parameters
            if (oldAbsPuProc.getParameters() != null) {
                newAbsPuProc.setParameters(new org.geotoolkit.sml.xml.v101.Parameters(oldAbsPuProc.getParameters()));
            }
        }
        if (oldMember.getRealProcess() instanceof System) {
            SystemType oldSystem = (SystemType) oldMember.getRealProcess();
            org.geotoolkit.sml.xml.v101.SystemType newSystem = (org.geotoolkit.sml.xml.v101.SystemType) newProcess;
            // components
            if (oldSystem.getComponents() != null) {
                newSystem.setComponents(new org.geotoolkit.sml.xml.v101.Components(oldSystem.getComponents()));
            }
            // positions
            if (oldSystem.getPositions() != null) {
                newSystem.setPositions(new org.geotoolkit.sml.xml.v101.Positions(oldSystem.getPositions()));
            }
            // connections
            if (oldSystem.getConnections() != null) {
                newSystem.setConnections(new org.geotoolkit.sml.xml.v101.Connections(oldSystem.getConnections()));
            }
        } else if (oldMember.getRealProcess() instanceof Component) {
            ComponentType oldComponent = (ComponentType) oldMember.getRealProcess();
            org.geotoolkit.sml.xml.v101.ComponentType newCompo = (org.geotoolkit.sml.xml.v101.ComponentType) newProcess;
            // method
            if (oldComponent.getMethod() != null) {
                newCompo.setMethod(new org.geotoolkit.sml.xml.v101.MethodPropertyType(oldComponent.getMethod()));
            }
        } else if (oldMember.getRealProcess() instanceof AbstractDataSource) {
            DataSourceType oldDataSource = (DataSourceType) oldMember.getRealProcess();
            org.geotoolkit.sml.xml.v101.DataSourceType newDataSource = (org.geotoolkit.sml.xml.v101.DataSourceType) newProcess;
            if (oldDataSource.getDataDefinition() != null) {
                newDataSource.setDataDefinition(new org.geotoolkit.sml.xml.v101.DataDefinition(oldDataSource.getDataDefinition()));
            }
            if (oldDataSource.getValues() != null) {
                newDataSource.setValues(new org.geotoolkit.sml.xml.v101.Values(oldDataSource.getValues()));
            }
            if (oldDataSource.getObservationReference() != null) {
                newDataSource.setObservationReference(new org.geotoolkit.sml.xml.v101.ObservationReference(oldDataSource.getObservationReference()));
            }
        } else if (oldMember.getRealProcess() instanceof AbstractProcessModel) {
            ProcessModelType oldProcessModel = (ProcessModelType) oldMember.getRealProcess();
            org.geotoolkit.sml.xml.v101.ProcessModelType newProcessModel = (org.geotoolkit.sml.xml.v101.ProcessModelType) newProcess;
            if (oldProcessModel.getMethod() != null) {
                newProcessModel.setMethod(new org.geotoolkit.sml.xml.v101.MethodPropertyType(oldProcessModel.getMethod()));
            }
        } else if (oldMember.getRealProcess() instanceof AbstractProcessChain) {
            ProcessChainType oldProcessChain = (ProcessChainType) oldMember.getRealProcess();
            org.geotoolkit.sml.xml.v101.ProcessChainType newProcessChain = (org.geotoolkit.sml.xml.v101.ProcessChainType) newProcess;
            // components
            if (oldProcessChain.getComponents() != null) {
                newProcessChain.setComponents(new org.geotoolkit.sml.xml.v101.Components(oldProcessChain.getComponents()));
            }
            // connections
            if (oldProcessChain.getConnections() != null) {
                newProcessChain.setConnections(new org.geotoolkit.sml.xml.v101.Connections(oldProcessChain.getConnections()));
            }
        } else if (oldMember.getRealProcess() instanceof ComponentArray) {
        // nothing to do
        } else {
            throw new IllegalArgumentException("Other sensor type than system ,component, processModel, processChain, componentArray or datasource are not yet convertible");
        }
        newMembers.add(new org.geotoolkit.sml.xml.v101.SensorML.Member(newProcess));
    }
    org.geotoolkit.sml.xml.v101.SensorML result = new org.geotoolkit.sml.xml.v101.SensorML("1.0.1", newMembers);
    return result;
}
Also used : ArrayList(java.util.ArrayList) SystemType(org.geotoolkit.sml.xml.v100.SystemType) History(org.geotoolkit.sml.xml.v100.History) Classification(org.geotoolkit.sml.xml.v100.Classification) DataSourceType(org.geotoolkit.sml.xml.v100.DataSourceType) Member(org.geotoolkit.sml.xml.v100.Member) Documentation(org.geotoolkit.sml.xml.v100.Documentation) AbstractProcessType(org.geotoolkit.sml.xml.v100.AbstractProcessType) Keywords(org.geotoolkit.sml.xml.v100.Keywords) LegalConstraint(org.geotoolkit.sml.xml.v100.LegalConstraint) Identification(org.geotoolkit.sml.xml.v100.Identification) ComponentType(org.geotoolkit.sml.xml.v100.ComponentType) Contact(org.geotoolkit.sml.xml.v100.Contact) Characteristics(org.geotoolkit.sml.xml.v100.Characteristics) Capabilities(org.geotoolkit.sml.xml.v100.Capabilities) ProcessModelType(org.geotoolkit.sml.xml.v100.ProcessModelType) ProcessChainType(org.geotoolkit.sml.xml.v100.ProcessChainType)

Aggregations

Member (com.example.demo.entity.order29.Member)5 GetMapping (org.springframework.web.bind.annotation.GetMapping)5 Member (com.eomcs.generic.ex02.Member)4 ArrayList (java.util.ArrayList)4 Member (org.openstack4j.model.image.v2.Member)4 Capabilities (org.geotoolkit.sml.xml.v100.Capabilities)3 Classification (org.geotoolkit.sml.xml.v100.Classification)3 Contact (org.geotoolkit.sml.xml.v100.Contact)3 Identification (org.geotoolkit.sml.xml.v100.Identification)3 Keywords (org.geotoolkit.sml.xml.v100.Keywords)3 Member (org.geotoolkit.sml.xml.v100.Member)3 InputStream (java.io.InputStream)2 HashMap (java.util.HashMap)2 JAXBElement (javax.xml.bind.JAXBElement)2 Unmarshaller (javax.xml.bind.Unmarshaller)2 DefaultIdentifier (org.apache.sis.metadata.iso.DefaultIdentifier)2 TimePositionType (org.geotoolkit.gml.xml.v311.TimePositionType)2 Classifier (org.geotoolkit.sml.xml.v100.Classifier)2 ClassifierList (org.geotoolkit.sml.xml.v100.ClassifierList)2 Identifier (org.geotoolkit.sml.xml.v100.Identifier)2