Example usage for java.lang String compareToIgnoreCase

List of usage examples for java.lang String compareToIgnoreCase

Introduction

In this page you can find the example usage for java.lang String compareToIgnoreCase.

Prototype

public int compareToIgnoreCase(String str) 

Source Link

Document

Compares two strings lexicographically, ignoring case differences.

Usage

From source file:com.krawler.workflow.bizservice.WorkflowServiceImpl.java

private void getGraphicsNodeInfo(Node node, ObjectInfo obj) {
    String name = "";
    NamedNodeMap attribute = node.getAttributes();
    for (int b = 0; b < attribute.getLength(); b++) {
        Node attribute1 = attribute.item(b);
        name = attribute1.getNodeName();
        if (name.compareToIgnoreCase("Height") == 0) {
            obj.height = attribute1.getNodeValue();
        } else if (name.compareToIgnoreCase("Width") == 0) {
            obj.width = attribute1.getNodeValue();
        }/*from   w w w.  ja  v  a2 s.  c  o  m*/
    }
    NodeList innerchildren = node.getChildNodes();
    for (int c = 0; c < innerchildren.getLength(); c++) {
        Node cordinateNode = innerchildren.item(c);
        if (cordinateNode.getNodeType() == Node.ELEMENT_NODE) {
            NamedNodeMap attr = cordinateNode.getAttributes();
            for (int b = 0; b < attr.getLength(); b++) {
                Node attribute1 = attr.item(b);
                name = attribute1.getNodeName();
                if (name.compareToIgnoreCase("XCoordinate") == 0) {
                    obj.xpos = attribute1.getNodeValue();
                } else if (name.compareToIgnoreCase("YCoordinate") == 0) {
                    obj.ypos = attribute1.getNodeValue();
                }
            }
        }
    }
}

From source file:com.architexa.diagrams.relo.jdt.parts.ClassEditPart.java

private List<MultiAddCommandAction> getRefMethodActions(List<Artifact> referencingMembers,
        final DirectedRel rel, final ReloController rc, IProgressMonitor monitor) {
    Collections.sort(referencingMembers, new Comparator<Artifact>() {
        public int compare(Artifact o1, Artifact o2) {
            String firstName = getRefCallerName(o1.toString());
            String secondName = getRefCallerName(o2.toString());
            return firstName.compareToIgnoreCase(secondName);
        }//w ww  . j a  v a 2s .c om
    });
    List<MultiAddCommandAction> refMethodsActions = new ArrayList<MultiAddCommandAction>();
    List<Artifact> tempArtList = new ArrayList<Artifact>(referencingMembers);
    Iterator<Artifact> itr = tempArtList.iterator();
    while (!referencingMembers.isEmpty()) {
        int i = 0;

        MultiAddCommandAction action1;
        while (i < MAX_LENGTH && itr.hasNext()) {
            // Add action for each artifact
            final Artifact relCU = itr.next();
            i++;

            referencingMembers.remove(relCU);
            action1 = new MultiAddCommandAction(getRefCallerName(relCU.toString()), getRootController()) {
                @Override
                public Command getCommand(Map<Artifact, ArtifactFragment> addedArtToAFMap) {
                    CompoundCommand tgtCmd = new CompoundCommand();
                    AddNodeAndRelCmd addCmd = new AddNodeAndRelCmd(rc, getArtFrag(), rel, (Artifact) relCU,
                            addedArtToAFMap);
                    tgtCmd.add(addCmd);
                    if (addCmd.getNewParentArtFrag() != null)
                        ((ReloDoc) rc.getRootArtifact()).showIncludedRelationships(tgtCmd,
                                addCmd.getNewArtFrag());
                    return tgtCmd;
                }
            };
            try {
                ImageDescriptor des = rc.getIconDescriptor(this, relCU);
                if (des != null)
                    action1.setImageDescriptor(des);
            } catch (Throwable t) {
                ClassEditPart.logger.error("Unexpected error while getting icon for: " + rel, t);
            }
            refMethodsActions.add(action1);
        }
    }
    return refMethodsActions;
}

From source file:org.dcm4che3.tool.probetc.ProbeTC.java

public ProbeTC(String probedae, String destinationaet, String sourceaet, String callingaet,
        String configurationType, File ldapConfigurationFile) throws ParseException {
    if (probedae == null || destinationaet == null || sourceaet == null || callingaet == null
            || configurationType == null) {
        LOG.error("null initialization parameter");
        throw new NullPointerException();
    }/* w  w w . j  a v a  2s.c o  m*/
    this.setConfigType(configurationType);
    this.setDestinationAET(destinationaet);

    if (ldapConfigurationFile != null && configurationType.compareToIgnoreCase("ldap") == 0)
        this.setLdapConfigurationFile(ldapConfigurationFile);
    else if (configurationType.compareToIgnoreCase("ldap") == 0) {
        LOG.error("Ldap properties file has to be a valid file");
        throw new NullPointerException();
    }
    this.setSourceAET(sourceaet);
    String tmpOption = probedae;
    String aeTitle = tmpOption.split("@")[0];

    if (tmpOption.split("@")[1] == null)
        throw new ParseException(rb.getString("invalid-probed-ae"));
    String host = tmpOption.split("@")[1].split(":")[0];
    int port = Integer.parseInt(tmpOption.split("@")[1].split(":")[1]);
    probedAET = aeTitle;
    Connection conn = new Connection();
    conn.setHostname(host);
    conn.setPort(port);
    conn.setConnectionInstalled(true);
    setDestination(conn);

    this.setProbedAE(new ApplicationEntity(aeTitle));
    this.getProbedAE().addConnection(conn);
    this.setCallingAET(callingaet);
}

From source file:org.iexhub.services.TranslateOutboundService.java

@GET
@Produces("application/xml")
public Response translateOutbound(@QueryParam("applicationId") String applicationId,
        @QueryParam("exchangeFormat") String exchangeFormat,
        @QueryParam("sourceDataSet") String sourceDataSet) {
    String srcMap = this.testOutputPath + "/EhrMap.xmi";
    String srcMdl = "EHR1.ModelName";
    String trgMdl = null;/*w  w  w .  j  av  a 2s . c  o  m*/
    String trgMsg = null;
    String cnvElm = "";
    File sourceDataSetFile = null;

    File rootDir = new File(System.getProperties().getProperty("user.dir"));

    // initialize the runtime, using the current folder as the root folder
    Mdmi.INSTANCE.initialize(rootDir);
    Mdmi.INSTANCE.start();

    String retVal = null;
    try {
        String trgMap = null;
        if (exchangeFormat.compareToIgnoreCase("ccda") == 0) {
            trgMap = this.testOutputPath + "/CCDAMap.9.1.xmi";
            trgMdl = "CCDMessageGroup.CCD";
            trgMsg = this.testOutputPath + "/target_minimal.xml";
        } else if (exchangeFormat.compareToIgnoreCase("fhir") == 0) {
            trgMap = this.testOutputPath + "/FhirPatient.xmi";
            trgMdl = "FHIRLocalTestMap.FHIRTest99";
            trgMsg = this.testOutputPath + "/PatientTarget.xml";
        } else {
            throw new InvalidExchangeFormatException(
                    "Error - invalid exchange format specified.  'CCDA' or 'FHIR' supported.  '" + srcMap
                            + "' does not exist");
        }

        // 1. check to make sure the maps and messages exist
        File f = Mdmi.INSTANCE.fileFromRelPath(srcMap);
        if (!f.exists() || !f.isFile()) {
            throw new SourceMapMissingException("Error - source map file '" + srcMap + "' does not exist");
        } else {
            f = Mdmi.INSTANCE.fileFromRelPath(trgMap);
            if (!f.exists() || !f.isFile()) {
                throw new TargetMapMissingException("Error - target map file '" + trgMap + "' does not exist");
            } else {
                sourceDataSetFile = Mdmi.INSTANCE.fileFromRelPath(sourceDataSet);
                if (!sourceDataSetFile.exists() || !sourceDataSetFile.isFile()) {
                    // The source message may be a URI - verify if that's the case...
                    sourceDataSetFile = new File(sourceDataSet);
                }

                if (!sourceDataSetFile.exists() || !sourceDataSetFile.isFile()) {
                    throw new SourceMsgMissingException(
                            "Error - source message file '" + sourceDataSet + "' does not exist");
                } else {
                    f = Mdmi.INSTANCE.fileFromRelPath(trgMsg);
                    if (!f.exists() || !f.isFile()) {
                        throw new TargetMapMissingException(
                                "Error - target message file '" + trgMsg + "' does not exist");
                    } else {
                        // 2. make sure the qualified message names are spelled right
                        String[] a = srcMdl.split("\\.");
                        if (a == null || a.length != 2) {
                            throw new InvalidSourceModelException("Error - invalid source model '" + srcMdl
                                    + "', must be formatted as MapName.MessageName");
                        } else {
                            String srcMapName = a[0];
                            String srcMsgMdl = a[1];

                            a = trgMdl.split("\\.");
                            if (a == null || a.length != 2) {
                                throw new InvalidTargetModelException("Error - invalid target model '" + trgMdl
                                        + "', must be formatted as MapName.MessageName");
                            } else {
                                try {
                                    String trgMapName = a[0];
                                    String trgMsgMdl = a[1];

                                    // 3. parse the elements array
                                    final ArrayList<String> elements = new ArrayList<String>();
                                    String[] ss = cnvElm.split(";");
                                    for (String s : ss) {
                                        if (s != null && s.trim().length() > 0) {
                                            elements.add(s);
                                        }
                                    }

                                    // 4. load the maps into the runtime.
                                    Mdmi.INSTANCE.getConfig()
                                            .putMapInfo(new MdmiConfig.MapInfo(srcMapName, srcMap));
                                    Mdmi.INSTANCE.getConfig()
                                            .putMapInfo(new MdmiConfig.MapInfo(trgMapName, trgMap));
                                    Mdmi.INSTANCE.getResolver().resolveConfig(Mdmi.INSTANCE.getConfig());

                                    // 5. Construct the parameters to the call based on the values passed in
                                    MdmiModelRef sMod = new MdmiModelRef(srcMapName, srcMsgMdl);
                                    MdmiMessage sMsg = new MdmiMessage(sourceDataSetFile);
                                    MdmiModelRef tMod = new MdmiModelRef(trgMapName, trgMsgMdl);
                                    MdmiMessage tMsg = new MdmiMessage(Mdmi.INSTANCE.fileFromRelPath(trgMsg));

                                    Map<String, MdmiBusinessElementReference> left = sMod.getModel()
                                            .getBusinessElementHashMap();

                                    Map<String, MdmiBusinessElementReference> right = tMod.getModel()
                                            .getBusinessElementHashMap();

                                    Equivalence<MdmiBusinessElementReference> valueEquivalence = new Equivalence<MdmiBusinessElementReference>() {
                                        @Override
                                        protected boolean doEquivalent(MdmiBusinessElementReference a,
                                                MdmiBusinessElementReference b) {
                                            return a.getUniqueIdentifier().equals(b.getUniqueIdentifier());
                                        }

                                        @Override
                                        protected int doHash(MdmiBusinessElementReference t) {
                                            return t.getUniqueIdentifier().hashCode();
                                        }
                                    };

                                    MapDifference<String, MdmiBusinessElementReference> differences = Maps
                                            .difference(left, right, valueEquivalence);

                                    Predicate<MdmiBusinessElementReference> predicate = new Predicate<MdmiBusinessElementReference>() {
                                        @Override
                                        public boolean apply(MdmiBusinessElementReference input) {

                                            if (!elements.isEmpty()) {
                                                for (String element : elements) {
                                                    if (input.getName().equalsIgnoreCase(element)) {
                                                        return true;
                                                    }

                                                }
                                                return false;
                                            }
                                            return true;

                                        }
                                    };
                                    ;

                                    ArrayList<MdmiBusinessElementReference> bers = new ArrayList<MdmiBusinessElementReference>();
                                    bers.addAll(Collections2.filter(differences.entriesInCommon().values(),
                                            predicate));

                                    MdmiTransferInfo ti = new MdmiTransferInfo(sMod, sMsg, tMod, tMsg, bers);
                                    ti.useDictionary = true;

                                    // 6. call the runtime
                                    Mdmi.INSTANCE.executeTransfer(ti);

                                    // 7. set the return value
                                    retVal = tMsg.getDataAsString();
                                } catch (Exception e) {
                                    throw new MessageTransformException(e.getMessage());
                                }
                            }
                        }
                    }
                }
            }
        }
    } catch (InvalidSourceModelException | InvalidTargetModelException | MessageTransformException
            | SourceMapMissingException | SourceMsgMissingException | TargetMapMissingException ex) {
        throw ex;
    } catch (Exception ex) {
        throw new UnexpectedServerException("Error - " + ex.getMessage());
    } finally {
        Mdmi.INSTANCE.stop();
    }

    return Response.status(Response.Status.OK).entity(retVal).type(MediaType.APPLICATION_XML).build();
}

From source file:org.etudes.mneme.impl.AssessmentStorageSample.java

/**
 * {@inheritDoc}//  w  w  w  . j  a  v a2 s .c  om
 */
public List<AssessmentImpl> getContextAssessments(String context, final AssessmentService.AssessmentsSort sort,
        Boolean publishedOnly) {
    fakeIt();

    List<AssessmentImpl> rv = new ArrayList<AssessmentImpl>();

    for (AssessmentImpl assessment : this.assessments.values()) {
        if (assessment.getContext().equals(context) && !assessment.getArchived() && !assessment.getMint()) {
            // filter out unpublished if requested (also ignoring invalid)
            if (publishedOnly) {
                if ((!assessment.getPublished()) || (!assessment.getIsValid()))
                    continue;
            }
            rv.add(new AssessmentImpl(assessment));
        }
    }

    // sort - use title as a secondary sort (or for title, use create date as secondary sort)
    // sort ascending first - reverse if descending
    Collections.sort(rv, new Comparator() {
        public int compare(Object arg0, Object arg1) {
            int rv = 0;
            AssessmentService.AssessmentsSort secondary = null;
            switch (sort) {
            case published_a:
            case published_d: {
                rv = ((Assessment) arg0).getPublished().compareTo(((Assessment) arg1).getPublished());
                secondary = AssessmentService.AssessmentsSort.title_a;
                break;
            }
            case title_a:
            case title_d: {
                String s0 = StringUtil.trimToZero(((Assessment) arg0).getTitle());
                String s1 = StringUtil.trimToZero(((Assessment) arg1).getTitle());
                rv = s0.compareToIgnoreCase(s1);
                secondary = AssessmentService.AssessmentsSort.cdate_a;
                break;
            }
            case type_a:
            case type_d: {
                rv = ((Assessment) arg0).getType().getSortValue()
                        .compareTo(((Assessment) arg1).getType().getSortValue());
                secondary = AssessmentService.AssessmentsSort.title_a;
                break;
            }
            case odate_a:
            case odate_d: {
                // no open date sorts low
                if (((Assessment) arg0).getDates().getOpenDate() == null) {
                    if (((Assessment) arg1).getDates().getOpenDate() == null) {
                        rv = 0;
                    } else {
                        rv = -1;
                    }
                } else if (((Assessment) arg1).getDates().getOpenDate() == null) {
                    rv = 1;
                } else {
                    rv = ((Assessment) arg0).getDates().getOpenDate()
                            .compareTo(((Assessment) arg1).getDates().getOpenDate());
                }
                secondary = AssessmentService.AssessmentsSort.title_a;
                break;
            }
            case ddate_a:
            case ddate_d: {
                // no open date sorts high
                if (((Assessment) arg0).getDates().getDueDate() == null) {
                    if (((Assessment) arg1).getDates().getDueDate() == null) {
                        rv = 0;
                    } else {
                        rv = 1;
                    }
                } else if (((Assessment) arg1).getDates().getDueDate() == null) {
                    rv = -1;
                } else {
                    rv = ((Assessment) arg0).getDates().getDueDate()
                            .compareTo(((Assessment) arg1).getDates().getDueDate());
                }
                secondary = AssessmentService.AssessmentsSort.title_a;
                break;
            }
            case cdate_a:
            case cdate_d: {
                rv = ((Assessment) arg0).getCreatedBy().getDate()
                        .compareTo(((Assessment) arg1).getCreatedBy().getDate());
                break;
            }
            }

            // kick in the secondary if needed
            AssessmentService.AssessmentsSort third = null;
            if ((rv == 0) && (secondary != null)) {
                switch (secondary) {
                case title_a:
                case title_d: {
                    String s0 = StringUtil.trimToZero(((Assessment) arg0).getTitle());
                    String s1 = StringUtil.trimToZero(((Assessment) arg1).getTitle());
                    rv = s0.compareToIgnoreCase(s1);
                    third = AssessmentService.AssessmentsSort.cdate_a;
                    break;
                }
                case cdate_a:
                case cdate_d: {
                    rv = ((Assessment) arg0).getCreatedBy().getDate()
                            .compareTo(((Assessment) arg1).getCreatedBy().getDate());
                    break;
                }
                }
            }

            // third sort
            if ((rv == 0) && (third != null)) {
                switch (third) {
                case cdate_a:
                case cdate_d: {
                    rv = ((Assessment) arg0).getCreatedBy().getDate()
                            .compareTo(((Assessment) arg1).getCreatedBy().getDate());
                    break;
                }
                }
            }

            return rv;
        }
    });

    // reverse for descending
    switch (sort) {
    case cdate_d:
    case ddate_d:
    case odate_d:
    case published_d:
    case title_d:
    case type_d: {
        Collections.reverse(rv);
    }
    }

    return rv;
}

From source file:org.wso2.carbon.module.mgt.service.ModuleAdminService.java

/**
 * return all parameters for this module (including inherited ones), where
 * each parameter is an XML fragment representing the "parameter" element
 *
 * @param moduleName module name of the module of which parameters are required
 * @param moduleVersion module version of the module of which parameters are required
 * @return params module parameter array
 * @throws ModuleMgtException is thrown in case of error
 *//*from   www.j av  a  2s.c  o  m*/
public String[] getModuleParameters(String moduleName, String moduleVersion) throws ModuleMgtException {

    AxisModule module = getAxisModule(moduleName, moduleVersion);
    if (module == null) {
        log.error("Module  " + module + "cannnot be found!");
        throw new ModuleMgtException(ModuleMgtException.ERROR, ModuleMgtMessageKeys.MODULE_NOT_FOUND);
    }

    ArrayList<String> parameters = new ArrayList<String>();

    ArrayList moduleParams = module.getParameters();

    for (Object serviceParam : moduleParams) {
        Parameter parameter = (Parameter) serviceParam;
        if (parameter.getParameterElement() != null) {
            parameters.add(parameter.getParameterElement().toString());
        }
    }

    Collections.sort(parameters, new Comparator<String>() {
        public int compare(String arg0, String arg1) {
            return arg0.compareToIgnoreCase(arg1);
        }
    });

    return parameters.toArray(new String[parameters.size()]);
}

From source file:org.etudes.mneme.impl.QuestionStorageSample.java

/**
 * {@inheritDoc}/*from   w  ww  .  j  a v  a 2  s.  c om*/
 */
protected List<QuestionImpl> findQuestions(String context, Pool pool,
        final QuestionService.FindQuestionsSort sort, String questionType, Integer pageNum, Integer pageSize,
        Boolean survey, Boolean valid) {
    if (context == null && pool == null)
        throw new IllegalArgumentException();
    if (context != null && pool != null)
        throw new IllegalArgumentException();

    fakeIt();

    List<QuestionImpl> rv = new ArrayList<QuestionImpl>();
    for (QuestionImpl question : this.questions.values()) {
        // skip historical unless looking at a specific pool
        if (question.getIsHistorical() && (pool == null))
            continue;
        if (question.getMint())
            continue;
        if ((questionType != null) && (!question.getType().equals(questionType)))
            continue;
        if ((pool != null) && (!question.getPool().equals(pool)))
            continue;
        if ((context != null) && (!question.getContext().equals(context)))
            continue;

        if ((survey != null) && (question.getIsSurvey() != survey))
            continue;
        if ((valid != null) && (question.getIsValid() != valid))
            continue;

        rv.add(new QuestionImpl(question));
    }

    // sort
    Collections.sort(rv, new Comparator() {
        public int compare(Object arg0, Object arg1) {
            int rv = 0;
            QuestionService.FindQuestionsSort secondary = null;
            switch (sort) {
            case type_a:
            case type_d: {
                // compare based on the localized type name
                rv = -1 * ((Question) arg0).getTypeSpecificQuestion().getPlugin().getPopularity()
                        .compareTo(((Question) arg1).getTypeSpecificQuestion().getPlugin().getPopularity());
                if (rv == 0) {
                    rv = ((Question) arg0).getTypeName().compareTo(((Question) arg1).getTypeName());
                }
                secondary = QuestionService.FindQuestionsSort.description_a;
                break;
            }
            case description_a:
            case description_d: {
                String s0 = StringUtil.trimToZero(((Question) arg0).getDescription());
                String s1 = StringUtil.trimToZero(((Question) arg1).getDescription());
                rv = s0.compareToIgnoreCase(s1);
                secondary = QuestionService.FindQuestionsSort.cdate_a;
                break;
            }
            case pool_difficulty_a:
            case pool_difficulty_d: {
                rv = ((Question) arg0).getPool().getDifficulty()
                        .compareTo(((Question) arg1).getPool().getDifficulty());
                secondary = QuestionService.FindQuestionsSort.description_a;
                break;
            }
            case pool_points_a:
            case pool_points_d: {
                rv = ((Question) arg0).getPool().getPoints().compareTo(((Question) arg1).getPool().getPoints());
                secondary = QuestionService.FindQuestionsSort.description_a;
                break;
            }
            case pool_title_a:
            case pool_title_d: {
                String s0 = StringUtil.trimToZero(((Question) arg0).getPool().getTitle());
                String s1 = StringUtil.trimToZero(((Question) arg1).getPool().getTitle());
                rv = s0.compareToIgnoreCase(s1);
                secondary = QuestionService.FindQuestionsSort.description_a;
                break;
            }
            case cdate_a:
            case cdate_d: {
                rv = ((Question) arg0).getCreatedBy().getDate()
                        .compareTo(((Question) arg1).getCreatedBy().getDate());
                break;
            }
            }

            // kick in the secondary if needed
            QuestionService.FindQuestionsSort third = null;
            if ((rv == 0) && (secondary != null)) {
                switch (secondary) {
                case description_a:
                case description_d: {
                    String s0 = StringUtil.trimToZero(((Question) arg0).getDescription());
                    String s1 = StringUtil.trimToZero(((Question) arg1).getDescription());
                    rv = s0.compareToIgnoreCase(s1);

                    third = QuestionService.FindQuestionsSort.cdate_a;
                    break;
                }
                case cdate_a:
                case cdate_d: {
                    rv = ((Question) arg0).getCreatedBy().getDate()
                            .compareTo(((Question) arg1).getCreatedBy().getDate());
                    break;
                }
                }
            }

            // third sort
            if ((rv == 0) && (third != null)) {
                switch (third) {
                case cdate_a:
                case cdate_d: {
                    rv = ((Question) arg0).getCreatedBy().getDate()
                            .compareTo(((Question) arg1).getCreatedBy().getDate());
                    break;
                }
                }
            }

            return rv;
        }
    });

    // reverse if descending
    switch (sort) {
    case cdate_d:
    case description_d:
    case pool_difficulty_d:
    case pool_points_d:
    case pool_title_d:
    case type_d: {
        Collections.reverse(rv);
    }
    }

    // page
    if ((pageNum != null) && (pageSize != null)) {
        // start at ((pageNum-1)*pageSize)
        int start = ((pageNum - 1) * pageSize);
        if (start < 0)
            start = 0;
        if (start > rv.size())
            start = rv.size() - 1;

        // end at ((pageNum)*pageSize)-1, or max-1, (note: subList is not inclusive for the end position)
        int end = ((pageNum) * pageSize);
        if (end < 0)
            end = 0;
        if (end > rv.size())
            end = rv.size();

        rv = rv.subList(start, end);
    }

    return rv;
}

From source file:org.apache.cordova.CordovaWebView.java

/**
 * Load Cordova configuration from res/xml/cordova.xml.
 * Approved list of URLs that can be loaded into DroidGap
 *      <access origin="http://server regexp" subdomains="true" />
 * Log level: ERROR, WARN, INFO, DEBUG, VERBOSE (default=ERROR)
 *      <log level="DEBUG" />/*w  ww  .  ja v  a 2 s.  c  o m*/
 */
private void loadConfiguration() {
    int id = getResources().getIdentifier("config", "xml", this.cordova.getActivity().getPackageName());
    if (id == 0) {
        id = getResources().getIdentifier("cordova", "xml", this.cordova.getActivity().getPackageName());
        Log.i("CordovaLog", "config.xml missing, reverting to cordova.xml");
    }
    if (id == 0) {
        LOG.i("CordovaLog", "cordova.xml missing. Ignoring...");
        return;
    }
    XmlResourceParser xml = getResources().getXml(id);
    int eventType = -1;
    while (eventType != XmlResourceParser.END_DOCUMENT) {
        if (eventType == XmlResourceParser.START_TAG) {
            String strNode = xml.getName();
            if (strNode.equals("access")) {
                String origin = xml.getAttributeValue(null, "origin");
                String subdomains = xml.getAttributeValue(null, "subdomains");
                if (origin != null) {
                    this.addWhiteListEntry(origin,
                            (subdomains != null) && (subdomains.compareToIgnoreCase("true") == 0));
                }
            } else if (strNode.equals("log")) {
                String level = xml.getAttributeValue(null, "level");
                LOG.i("CordovaLog", "Found log level %s", level);
                if (level != null) {
                    LOG.setLogLevel(level);
                }
            } else if (strNode.equals("preference")) {
                String name = xml.getAttributeValue(null, "name");
                String value = xml.getAttributeValue(null, "value");

                LOG.i("CordovaLog", "Found preference for %s=%s", name, value);
                Log.d("CordovaLog", "Found preference for " + name + "=" + value);

                // Save preferences in Intent
                this.cordova.getActivity().getIntent().putExtra(name, value);
            }
        }
        try {
            eventType = xml.next();
        } catch (XmlPullParserException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    // Init preferences
    if ("true".equals(this.getProperty("useBrowserHistory", "false"))) {
        this.useBrowserHistory = true;
    } else {
        this.useBrowserHistory = false;
    }

    if ("true".equals(this.getProperty("fullscreen", "false"))) {
        this.cordova.getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        this.cordova.getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
}

From source file:gov.nih.nci.evs.browser.utils.MappingSearchUtils.java

public ResolvedConceptReferencesIteratorWrapper searchByNameOrCode(String scheme, String version,
        String matchText, String matchAlgorithm, int maxToReturn, String searchTarget) {
    if (scheme == null)
        return null;

    Vector schemes = new Vector();
    schemes.add(scheme);/*  www . j a  v a2  s  . c o m*/
    Vector versions = new Vector();
    versions.add(version);
    if (searchTarget.compareToIgnoreCase(SearchUtils.SEARCH_BY_CODE_ONLY) == 0) {
        return searchByCode(schemes, versions, matchText, matchAlgorithm, SearchContext.SOURCE_OR_TARGET_CODES,
                maxToReturn);
    } else {
        return searchByName(schemes, versions, matchText, matchAlgorithm, maxToReturn);
    }
}

From source file:org.iexhub.services.TranslateInboundService.java

@GET
@Produces("application/xml")
public Response translateInbound(@QueryParam("applicationId") String applicationId,
        @QueryParam("exchangeFormat") String exchangeFormat,
        @QueryParam("sourceDataSet") String sourceDataSet) {
    String trgMap = this.testOutputPath + "/EhrMap.xmi";
    String trgMdl = "EHR1.ModelName";
    String trgMsg = this.testOutputPath + "/targetehr.xml";
    String srcMap = null;/*w  w w  . jav a2 s  .  c om*/
    String srcMdl = null;
    String cnvElm = "";
    File sourceDataSetFile = null;

    File rootDir = new File(System.getProperties().getProperty(this.testOutputPath));

    // initialize the runtime, using the current folder as the root folder
    Mdmi.INSTANCE.initialize(rootDir);
    Mdmi.INSTANCE.start();

    String retVal = null;
    try {
        if (exchangeFormat.compareToIgnoreCase("ccda") == 0) {
            srcMap = this.testOutputPath + "/CCDAMap.9.1.xmi";
            srcMdl = "CCDMessageGroup.CCD";
        } else if (exchangeFormat.compareToIgnoreCase("fhir") == 0) {
            srcMap = this.testOutputPath + "/FhirPatient.xmi";
            srcMdl = "FHIRLocalTestMap.FHIRTest99";
        } else {
            throw new InvalidExchangeFormatException(
                    "Error - invalid exchange format specified.  'CCDA' or 'FHIR' supported.  '" + srcMap
                            + "' does not exist");
        }

        // 1. check to make sure the maps and messages exist
        File f = Mdmi.INSTANCE.fileFromRelPath(srcMap);
        if (!f.exists() || !f.isFile()) {
            throw new SourceMapMissingException("Error - source map file '" + srcMap + "' does not exist");
        } else {
            f = Mdmi.INSTANCE.fileFromRelPath(trgMap);
            if (!f.exists() || !f.isFile()) {
                throw new TargetMapMissingException("Error - target map file '" + trgMap + "' does not exist");
            } else {
                sourceDataSetFile = Mdmi.INSTANCE.fileFromRelPath(sourceDataSet);
                if (!sourceDataSetFile.exists() || !sourceDataSetFile.isFile()) {
                    // The source message may be a URI - verify if that's the case...
                    sourceDataSetFile = new File(sourceDataSet);
                }

                if (!sourceDataSetFile.exists() || !sourceDataSetFile.isFile()) {
                    throw new SourceMsgMissingException(
                            "Error - source message file '" + sourceDataSet + "' does not exist");
                } else {
                    f = Mdmi.INSTANCE.fileFromRelPath(trgMsg);
                    if (!f.exists() || !f.isFile()) {
                        throw new TargetMapMissingException(
                                "Error - target message file '" + trgMsg + "' does not exist");
                    } else {
                        // 2. make sure the qualified message names are spelled right
                        String[] a = srcMdl.split("\\.");
                        if (a == null || a.length != 2) {
                            throw new InvalidSourceModelException("Error - invalid source model '" + srcMdl
                                    + "', must be formatted as MapName.MessageName");
                        } else {
                            String srcMapName = a[0];
                            String srcMsgMdl = a[1];

                            a = trgMdl.split("\\.");
                            if (a == null || a.length != 2) {
                                throw new InvalidTargetModelException("Error - invalid target model '" + trgMdl
                                        + "', must be formatted as MapName.MessageName");
                            } else {
                                try {
                                    String trgMapName = a[0];
                                    String trgMsgMdl = a[1];

                                    // 3. parse the elements array
                                    final ArrayList<String> elements = new ArrayList<String>();
                                    String[] ss = cnvElm.split(";");
                                    for (String s : ss) {
                                        if (s != null && s.trim().length() > 0) {
                                            elements.add(s);
                                        }
                                    }

                                    // 4. load the maps into the runtime.
                                    Mdmi.INSTANCE.getConfig()
                                            .putMapInfo(new MdmiConfig.MapInfo(srcMapName, srcMap));
                                    Mdmi.INSTANCE.getConfig()
                                            .putMapInfo(new MdmiConfig.MapInfo(trgMapName, trgMap));
                                    Mdmi.INSTANCE.getResolver().resolveConfig(Mdmi.INSTANCE.getConfig());

                                    // 5. Construct the parameters to the call based on the values passed in
                                    MdmiModelRef sMod = new MdmiModelRef(srcMapName, srcMsgMdl);
                                    MdmiMessage sMsg = new MdmiMessage(sourceDataSetFile);
                                    MdmiModelRef tMod = new MdmiModelRef(trgMapName, trgMsgMdl);
                                    MdmiMessage tMsg = new MdmiMessage(Mdmi.INSTANCE.fileFromRelPath(trgMsg));

                                    Map<String, MdmiBusinessElementReference> left = sMod.getModel()
                                            .getBusinessElementHashMap();

                                    Map<String, MdmiBusinessElementReference> right = tMod.getModel()
                                            .getBusinessElementHashMap();

                                    Equivalence<MdmiBusinessElementReference> valueEquivalence = new Equivalence<MdmiBusinessElementReference>() {
                                        @Override
                                        protected boolean doEquivalent(MdmiBusinessElementReference a,
                                                MdmiBusinessElementReference b) {
                                            return a.getUniqueIdentifier().equals(b.getUniqueIdentifier());
                                        }

                                        @Override
                                        protected int doHash(MdmiBusinessElementReference t) {
                                            return t.getUniqueIdentifier().hashCode();
                                        }
                                    };

                                    MapDifference<String, MdmiBusinessElementReference> differences = Maps
                                            .difference(left, right, valueEquivalence);

                                    Predicate<MdmiBusinessElementReference> predicate = new Predicate<MdmiBusinessElementReference>() {
                                        @Override
                                        public boolean apply(MdmiBusinessElementReference input) {

                                            if (!elements.isEmpty()) {
                                                for (String element : elements) {
                                                    if (input.getName().equalsIgnoreCase(element)) {
                                                        return true;
                                                    }

                                                }
                                                return false;
                                            }
                                            return true;

                                        }
                                    };
                                    ;

                                    ArrayList<MdmiBusinessElementReference> bers = new ArrayList<MdmiBusinessElementReference>();
                                    bers.addAll(Collections2.filter(differences.entriesInCommon().values(),
                                            predicate));

                                    MdmiTransferInfo ti = new MdmiTransferInfo(sMod, sMsg, tMod, tMsg, bers);
                                    ti.useDictionary = true;

                                    // 6. call the runtime
                                    Mdmi.INSTANCE.executeTransfer(ti);

                                    // 7. set the return value
                                    retVal = tMsg.getDataAsString();
                                } catch (Exception e) {
                                    throw new MessageTransformException(e.getMessage());
                                }
                            }
                        }
                    }
                }
            }
        }
    } catch (InvalidSourceModelException | InvalidTargetModelException | MessageTransformException
            | SourceMapMissingException | SourceMsgMissingException | TargetMapMissingException ex) {
        throw ex;
    } catch (Exception ex) {
        throw new UnexpectedServerException("Error - " + ex.getMessage());
    } finally {
        Mdmi.INSTANCE.stop();
    }

    return Response.status(Response.Status.OK).entity(retVal).type(MediaType.APPLICATION_XML).build();
}