Android Open Source - sana Logic Base






From Project

Back to project page sana.

License

The source code is released under:

Copyright (c) 2010, Moca All rights reserved. The source code for Moca is licensed under the BSD license as follows: Redistribution and use in source and binary forms, with or without modification, ...

If you think the Android project sana listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.moca.procedure.branching;
// w  w w.  j a v  a 2s . c o  m
import java.util.HashMap;

import org.moca.procedure.ProcedureElement;
import org.moca.procedure.ProcedureParseException;
import org.moca.procedure.branching.Criterion.CriterionType;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

/**
 * LogicBase is a Criteria subclass that serves as a container for a single
 * Criterion.
 */      
public  class LogicBase extends Criteria {
    private Criterion criterion;
    
    public LogicBase(Criterion crit) {
        this.criterion = crit;
    }
    
    public boolean criteriaMet() {
        return criterion.criterionMet();
    }
    
    public static LogicBase fromXML(Node node, HashMap<String, ProcedureElement> elts) throws ProcedureParseException {
        if(!node.getNodeName().equals("Criteria")) {
            throw new ProcedureParseException("LogicBase got NodeName " + node.getNodeName());
        }
        if(node.getChildNodes().getLength() != 0) {
            throw new ProcedureParseException("A single criteria has children.");
        }
        
        NamedNodeMap attributes = node.getAttributes();
        Node typeNode = attributes.getNamedItem("type");
        String type = "";
        CriterionType critType;
        if(typeNode != null) {                
            type = typeNode.getNodeValue();
            if (type.equals("EQUALS"))
                critType = CriterionType.EQUALS;
            else if (type.equals("GREATER"))
                critType = CriterionType.GREATER;
            else if (type.equals("LESS"))
                critType = CriterionType.LESS;
            else
                throw new ProcedureParseException("LogicBase bad type for NodeName " + node.getNodeName());
        } else {
            throw new ProcedureParseException("LogicBase no type for NodeName " + node.getNodeName());
        }
        Node elementIdNode = attributes.getNamedItem("id");
        String elementId = "";
        if(elementIdNode != null) {                
            elementId = elementIdNode.getNodeValue();
        } else {
            throw new ProcedureParseException("LogicBase no id for NodeName " + node.getNodeName());
        }            
        Node valueNode = attributes.getNamedItem("value");
        String value = "";
        if(valueNode != null) {                
            value = valueNode.getNodeValue();
        } else {
            throw new ProcedureParseException("LogicBase no value for NodeName " + node.getNodeName());
        }
        ProcedureElement elt = elts.get(elementId);
        if (elt == null)
            throw new ProcedureParseException("LogicBase cannot resolve element #" + elementId);
        return new LogicBase(new Criterion(critType, elt, value));
    }
}




Java Source Code List

.Moca.java
org.moca.Constants.java
org.moca.ImagePreviewDialog.java
org.moca.ScalingImageAdapter.java
org.moca.SelectableImageView.java
org.moca.activity.NotificationList.java
org.moca.activity.NotificationViewer.java
org.moca.activity.PatientInfoDialog.java
org.moca.activity.ProcedureRunner.java
org.moca.activity.ProceduresList.java
org.moca.activity.SavedProcedureList.java
org.moca.activity.Settings.java
org.moca.db.EncounterDAO.java
org.moca.db.EventDAO.java
org.moca.db.EventProvider.java
org.moca.db.Event.java
org.moca.db.ImageProvider.java
org.moca.db.MocaDB.java
org.moca.db.NotificationMessage.java
org.moca.db.NotificationProvider.java
org.moca.db.PatientInfo.java
org.moca.db.PatientProvider.java
org.moca.db.PatientValidator.java
org.moca.db.ProcedureDAO.java
org.moca.db.ProcedureProvider.java
org.moca.db.SavedProcedureProvider.java
org.moca.db.SoundProvider.java
org.moca.media.AudioPlayer.java
org.moca.net.MDSCode.java
org.moca.net.MDSInterface.java
org.moca.net.MDSNotification.java
org.moca.net.MDSResult.java
org.moca.net.SMSReceive.java
org.moca.procedure.BinaryUploadElement.java
org.moca.procedure.DateElement.java
org.moca.procedure.GpsElement.java
org.moca.procedure.MultiSelectElement.java
org.moca.procedure.PatientIdElement.java
org.moca.procedure.PictureElement.java
org.moca.procedure.ProcedureElement.java
org.moca.procedure.ProcedurePage.java
org.moca.procedure.ProcedureParseException.java
org.moca.procedure.Procedure.java
org.moca.procedure.RadioElement.java
org.moca.procedure.SelectElement.java
org.moca.procedure.SoundElement.java
org.moca.procedure.TextElement.java
org.moca.procedure.TextEntryElement.java
org.moca.procedure.ValidationError.java
org.moca.procedure.branching.Criteria.java
org.moca.procedure.branching.Criterion.java
org.moca.procedure.branching.LogicAnd.java
org.moca.procedure.branching.LogicBase.java
org.moca.procedure.branching.LogicNot.java
org.moca.procedure.branching.LogicOr.java
org.moca.service.BackgroundUploader.java
org.moca.service.QueueManager.java
org.moca.service.ServiceConnector.java
org.moca.service.ServiceListener.java
org.moca.task.CheckCredentialsTask.java
org.moca.task.ImageProcessingTaskRequest.java
org.moca.task.ImageProcessingTask.java
org.moca.task.MDSSyncTask.java
org.moca.task.PatientLookupListener.java
org.moca.task.PatientLookupTask.java
org.moca.task.ResetDatabaseTask.java
org.moca.task.ValidationListener.java
org.moca.util.MocaUtil.java
org.moca.util.UserDatabase.java