Code example for Vector

Methods: firstElement, isEmpty

0
 
    private boolean injectPatientId(org.javarosa.core.model.instance.FormInstance datamodel, Integer patientId) {
        TreeElement root = datamodel.getRoot();
        if (root != null && root.getName().equalsIgnoreCase("form")) {
            Vector<TreeElement> children = root.getChildrenWithName("patient");
            if (!children.isEmpty()) {
                TreeElement patientElement = children.firstElement();
                children = patientElement.getChildrenWithName("patient.patient_id");
                if (!children.isEmpty()) {
                    TreeElement patientIdElement = children.firstElement();
                    patientIdElement.setAnswer(new IntegerData(patientId));
                    return true; 
                } 
            } 
        } 
         
        return false; 
    } 
     
    private boolean exportXmlFile(ByteArrayPayload payload, String path) {