Example usage for java.util StringTokenizer countTokens

List of usage examples for java.util StringTokenizer countTokens

Introduction

In this page you can find the example usage for java.util StringTokenizer countTokens.

Prototype

public int countTokens() 

Source Link

Document

Calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception.

Usage

From source file:gda.function.lookup.LookupTable.java

/**
 * @param string//from w w w. j  a va 2 s.  c om
 * @return an array of token positions
 */
private int[] calculateDecimalPlaces(String string) {
    int[] values;
    String nextToken;
    int index;

    StringTokenizer strtok = new StringTokenizer(string, ", \t");

    values = new int[strtok.countTokens()];
    int i = 0;
    while (strtok.hasMoreTokens()) {
        nextToken = strtok.nextToken();
        index = nextToken.indexOf('.');
        if (index == -1)
            values[i] = 0;
        else
            values[i] = nextToken.length() - index - 1;
        i++;
    }

    return values;
}

From source file:io.spring.initializr.metadata.Dependency.java

/**
 * Validate the dependency and complete its state based on the available information.
 *//*from   ww  w.j a v  a 2  s. c  o m*/
public void resolve() {
    if (getId() == null) {
        if (!hasCoordinates()) {
            throw new InvalidInitializrMetadataException(
                    "Invalid dependency, should have at least an id or a groupId/artifactId pair.");
        }
        generateId();
    } else if (!hasCoordinates()) {
        // Let"s build the coordinates from the id
        StringTokenizer st = new StringTokenizer(getId(), ":");
        if (st.countTokens() == 1) { // assume spring-boot-starter
            asSpringBootStarter(getId());
        } else if (st.countTokens() == 2 || st.countTokens() == 3) {
            groupId = st.nextToken();
            artifactId = st.nextToken();
            if (st.hasMoreTokens()) {
                version = st.nextToken();
            }
        } else {
            throw new InvalidInitializrMetadataException(
                    "Invalid dependency, id should have the form groupId:artifactId[:version] but got "
                            + getId());
        }
    }
    links.forEach(Link::resolve);
    updateVersionRanges(VersionParser.DEFAULT);
}

From source file:it.doqui.index.ecmengine.business.personalization.security.acl.ACLEntryAfterInvocationProvider.java

public ResultSet decideLucene(Authentication authentication, Object object, ConfigAttributeDefinition config,
        LuceneResultSet resultSet) throws AccessDeniedException {

    if (log.isDebugEnabled()) {
        log.debug("[ACLEntryAfterInvocationProvider::decideLucene] BEGIN");
        log.debug("[ACLEntryAfterInvocationProvider::decideLucene] resultset.length: " + resultSet.length());
        for (int i = 0; i < resultSet.length(); i++) {
            log.debug("[ACLEntryAfterInvocationProvider::decideLucene] resultset[" + i + "]: "
                    + resultSet.getDocument(i));
        }/*from  w w w.  j  a  v  a  2 s .c  om*/
    }

    try {
        final long prepareStart = System.currentTimeMillis();
        HashMap<Long, Integer> toCheck = new HashMap<Long, Integer>();
        Set<String> authorities = readersService.getAuthoritiesForCurrentUser();

        if (log.isDebugEnabled()) {
            log.debug("[ACLEntryAfterInvocationProvider::decideLucene] Authorities: " + authorities);
        }

        FilteringResultSet filteringResultSet = new FilteringResultSet(resultSet);
        ResultSetMetaData rsInfo = resultSet.getResultSetMetaData();

        Integer maxSize = null;
        if (rsInfo.getSearchParameters().getLimitBy() == LimitBy.FINAL_SIZE) {
            maxSize = new Integer(rsInfo.getSearchParameters().getLimit());
        }

        if (authorities == null) {
            // L'utente ha privilegi amministrativi
            if (maxSize != null && maxSize.intValue() > 0 && resultSet.length() > maxSize.intValue()) {

                // Filtriamo in base alla dimensione massima impostata
                for (int i = 0; i < resultSet.length(); i++) {
                    filteringResultSet.setIncluded(i, (i < maxSize.intValue()));
                }

                filteringResultSet.setResultSetMetaData(new SimpleResultSetMetaData(LimitBy.FINAL_SIZE,
                        PermissionEvaluationMode.EAGER, rsInfo.getSearchParameters()));

                return filteringResultSet;
            } else {

                for (int i = 0; i < resultSet.length(); i++) {
                    filteringResultSet.setIncluded(i, true);
                }

                // La lunghezza del RS originale non supera la dimensione massima impostata
                filteringResultSet.setResultSetMetaData(new SimpleResultSetMetaData(LimitBy.UNLIMITED,
                        PermissionEvaluationMode.EAGER, rsInfo.getSearchParameters()));

                return filteringResultSet; // L'utente ha i privilegi amministrativi o di sistema.
            }
        }
        if (log.isDebugEnabled()) {
            log.debug(
                    "[ACLEntryAfterInvocationProvider::decideLucene] Esecuzione codice per utente non admin.");
        }

        PermissionReference required = null;
        boolean configContainsSupportedDefinitions = false;

        Iterator<?> iter = config.getConfigAttributes();

        while (iter.hasNext()) {
            ConfigAttribute attr = (ConfigAttribute) iter.next();

            if (supports(attr)) {
                configContainsSupportedDefinitions = true;
            }

            if (attr.getAttribute().startsWith(AFTER_ACL_NODE)) {
                StringTokenizer st = new StringTokenizer(attr.getAttribute(), ".", false);
                if (st.countTokens() != 3) {
                    throw new ACLEntryVoterException(
                            "There must be three . separated tokens in each config attribute");
                }
                @SuppressWarnings("unused")
                String typeString = st.nextToken();
                String qNameString = st.nextToken();
                String permissionString = st.nextToken();

                required = new SimplePermissionReference(
                        QName.createQName(qNameString, getNamespacePrefixResolver()), permissionString);
            }
        }

        // Insieme dei permission group che includono il permesso di Read
        if (log.isDebugEnabled()) {
            log.debug("[ACLEntryAfterInvocationProvider::decideLucene] required permission: " + required);
        }
        Set<PermissionReference> permissions = new HashSet<PermissionReference>(10);
        permissions.addAll(modelDao.getGrantingPermissions(required));

        permissions.add(modelDao.getPermissionReference(null, PermissionService.ALL_PERMISSIONS));

        for (int i = 0; i < resultSet.length(); i++) {
            if (log.isDebugEnabled()) {
                log.debug("[ACLEntryAfterInvocationProvider::decideLucene] i: " + i);
                log.debug("[ACLEntryAfterInvocationProvider::decideLucene] document[i]: "
                        + resultSet.getDocument(i));
            }

            String id = resultSet.getDocument(i).get("DBID");

            if (log.isDebugEnabled()) {
                log.debug("[ACLEntryAfterInvocationProvider::decideLucene] id: " + id);
            }

            toCheck.put(new Long(id), new Integer(i));
        }

        final List<Long> toCheckList = new ArrayList<Long>(toCheck.keySet());

        if (log.isDebugEnabled()) {
            final long prepareStop = System.currentTimeMillis();
            log.debug("[ACLEntryAfterInvocationProvider::decideLucene] Prepare duration: "
                    + (prepareStop - prepareStart) + " ms [toCheck: " + toCheck.size() + "]");
        }

        final long start = System.currentTimeMillis();
        List<Long> readables = aclCheckDao.checkHasPermissionsOnNodes(toCheckList, authorities, permissions);

        if (log.isDebugEnabled()) {
            final long stop = System.currentTimeMillis();
            log.debug("[ACLEntryAfterInvocationProvider::decideLucene] Check duration: " + (stop - start)
                    + " ms [readables: " + readables.size() + "]");
        }

        final long filteringStart = System.currentTimeMillis();

        for (Long readable : readables) {
            filteringResultSet.setIncluded(toCheck.get(readable).intValue(), true);
        }

        if (!configContainsSupportedDefinitions) {
            if (maxSize == null) {
                return resultSet;
            } else if (resultSet.length() > maxSize.intValue()) {
                for (int i = 0; i < maxSize.intValue(); i++) {
                    filteringResultSet.setIncluded(i, true);
                }
                filteringResultSet.setResultSetMetaData(new SimpleResultSetMetaData(LimitBy.FINAL_SIZE,
                        PermissionEvaluationMode.EAGER, rsInfo.getSearchParameters()));
            } else {
                for (int i = 0; i < resultSet.length(); i++) {
                    filteringResultSet.setIncluded(i, true);
                }
                filteringResultSet.setResultSetMetaData(new SimpleResultSetMetaData(LimitBy.UNLIMITED,
                        PermissionEvaluationMode.EAGER, rsInfo.getSearchParameters()));
            }
        } else {
            if (maxSize != null) {
                if (log.isDebugEnabled()) {
                    log.debug("[ACLEntryAfterInvocationProvider::decideLucene] Max RS size: "
                            + maxSize.toString());
                }

                int counter = 0;
                int included = 0;

                maxSize = (maxSize <= resultSet.length()) ? maxSize : resultSet.length();

                while (counter < maxSize) {
                    if (filteringResultSet.getIncluded(counter)) {
                        included++;
                    }
                    counter++;
                }
                while (counter < resultSet.length()) {
                    filteringResultSet.setIncluded(counter, false);
                    counter++;
                }
                filteringResultSet.setResultSetMetaData(new SimpleResultSetMetaData(LimitBy.FINAL_SIZE,
                        PermissionEvaluationMode.EAGER, rsInfo.getSearchParameters()));
            }
        }
        // set the default, unlimited result set type
        filteringResultSet.setResultSetMetaData(new SimpleResultSetMetaData(LimitBy.UNLIMITED,
                PermissionEvaluationMode.EAGER, rsInfo.getSearchParameters()));

        if (log.isDebugEnabled()) {
            final long filteringStop = System.currentTimeMillis();
            log.debug("[ACLEntryAfterInvocationProvider::decideLucene] Filtering duration: "
                    + (filteringStop - filteringStart) + " ms");
        }

        return filteringResultSet;
    } finally {
        log.debug("[ACLEntryAfterInvocationProvider::decideLucene] END");
    }
}

From source file:eionet.gdem.conversion.odf.OdsReader.java

@Override
public Map<String, String> getSheetSchemas() {
    Map<String, String> resultMap = new LinkedHashMap<String, String>();
    Hashtable userMetadata = metadata.getUserDefined();

    if (userMetadata.containsKey(TBL_SCHEMAS_ATTR_NAME)) {
        String ret = (String) userMetadata.get(TBL_SCHEMAS_ATTR_NAME);
        if (Utils.isNullStr(ret)) {
            return resultMap;
        }/*from w ww. j  a  va2 s  .c o  m*/

        StringTokenizer stTbl = new StringTokenizer(ret, TBL_SEPARATOR);
        if (stTbl.countTokens() == 0) {
            return resultMap;
        }
        resultMap = new HashMap<String, String>();
        while (stTbl.hasMoreTokens()) {
            String tbl = stTbl.nextToken();
            StringTokenizer stTblProps = new StringTokenizer(tbl, TBL_PROPERTIES_SEPARATOR);
            if (stTblProps.countTokens() < 2) {
                continue;
            }

            String tblName = null;
            String tblSchema = null;

            while (stTblProps.hasMoreTokens()) {
                String token = stTblProps.nextToken();
                if (token.startsWith(TABLE_NAME)) {
                    tblName = token.substring(TABLE_NAME.length());
                }
                if (token.startsWith(TABLE_SCHEMA_URL)) {
                    tblSchema = token.substring(TABLE_SCHEMA_URL.length());
                }
            }
            if (Utils.isNullStr(tblName) || Utils.isNullStr(tblSchema)) {
                continue;
            }

            // check if table exists
            if (spreadsheet != null && !spreadsheet.tableExists(tblName)) {
                continue;
            }
            if (!resultMap.containsKey(tblName)) {
                resultMap.put(tblName, tblSchema);
            }
        }

    }
    return resultMap;
}

From source file:org.alfresco.web.app.servlet.ExternalAccessServlet.java

/**
 * @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *///w  w  w .  ja v  a 2  s.  c  om
protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    String uri = req.getRequestURI();

    if (logger.isDebugEnabled())
        logger.debug(
                "Processing URL: " + uri + (req.getQueryString() != null ? ("?" + req.getQueryString()) : ""));

    AuthenticationStatus status = servletAuthenticate(req, res);
    if (status == AuthenticationStatus.Failure) {
        return;
    }

    setNoCacheHeaders(res);

    uri = uri.substring(req.getContextPath().length());
    StringTokenizer t = new StringTokenizer(uri, "/");
    int tokenCount = t.countTokens();
    if (tokenCount < 2) {
        throw new IllegalArgumentException(
                "Externally addressable URL did not contain all required args: " + uri);
    }

    t.nextToken(); // skip servlet name

    String outcome = t.nextToken();

    // get rest of the tokens arguments
    String[] args = new String[tokenCount - 2];
    for (int i = 0; i < tokenCount - 2; i++) {
        args[i] = t.nextToken();
    }

    if (logger.isDebugEnabled())
        logger.debug("External outcome found: " + outcome);

    // we almost always need this bean reference
    FacesContext fc = FacesHelper.getFacesContext(req, res, getServletContext());
    BrowseBean browseBean = (BrowseBean) FacesHelper.getManagedBean(fc, "BrowseBean");

    // get services we need
    ServiceRegistry serviceRegistry = getServiceRegistry(getServletContext());
    PermissionService permissionService = serviceRegistry.getPermissionService();

    // as we are potentially coming in from an external app reset the view stack
    Stack viewStack = (Stack) fc.getExternalContext().getSessionMap().get("_alfViewStack");
    if (viewStack != null) {
        viewStack.clear();

        if (logger.isDebugEnabled())
            logger.debug("Cleared view stack");
    }

    // setup is required for certain outcome requests
    if (OUTCOME_DOCDETAILS.equals(outcome)) {
        NodeRef nodeRef = null;

        if (args[0].equals(WebDAVServlet.WEBDAV_PREFIX)) {
            nodeRef = resolveWebDAVPath(fc, args);
        } else if (args.length == 3) {
            StoreRef storeRef = new StoreRef(args[0], args[1]);
            nodeRef = new NodeRef(storeRef, args[2]);
        }

        if (nodeRef != null) {
            // check that the user has at least READ access - else redirect to an error or login page
            if (!checkAccess(req, res, nodeRef, PermissionService.READ_CONTENT, true)) {
                return;
            }

            // setup the Document on the browse bean
            browseBean.setupContentAction(nodeRef.getId(), true);
        }

        // perform the appropriate JSF navigation outcome
        NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
        navigationHandler.handleNavigation(fc, null, "dialog:" + OUTCOME_DOCDETAILS);
    } else if (OUTCOME_SPACEDETAILS.equals(outcome)) {
        NodeRef nodeRef = null;

        if (args[0].equals(WebDAVServlet.WEBDAV_PREFIX)) {
            nodeRef = resolveWebDAVPath(fc, args);
        } else if (args.length == 3) {
            StoreRef storeRef = new StoreRef(args[0], args[1]);
            nodeRef = new NodeRef(storeRef, args[2]);
        }

        if (nodeRef != null) {
            // check that the user has at least READ access - else redirect to an error or login page
            if (!checkAccess(req, res, nodeRef, PermissionService.READ_CONTENT, true)) {
                return;
            }

            // setup the Space on the browse bean
            browseBean.setupSpaceAction(nodeRef.getId(), true);
        }

        // perform the appropriate JSF navigation outcome
        NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
        navigationHandler.handleNavigation(fc, null, "dialog:" + OUTCOME_SPACEDETAILS);
    } else if (OUTCOME_BROWSE.equals(outcome)) {
        NodeRef nodeRef = null;

        if (args.length != 0 && args[0].equals(WebDAVServlet.WEBDAV_PREFIX)) {
            nodeRef = resolveWebDAVPath(fc, args);
        } else if (args.length >= 3) {
            int offset = 0;

            offset = args.length - 3;
            StoreRef storeRef = new StoreRef(args[0 + offset], args[1 + offset]);
            nodeRef = new NodeRef(storeRef, args[2 + offset]);
        }

        if (nodeRef != null) {
            // check that the user has at least READ access - else redirect to an error or login page
            if (!checkAccess(req, res, nodeRef, PermissionService.READ_CONTENT, true)) {
                return;
            }

            // this call sets up the current node Id, and updates or initialises the
            // breadcrumb component with the selected node as appropriate.
            browseBean.updateUILocation(nodeRef);

            // force a "late" refresh of the BrowseBean to handle external servlet access URL
            browseBean.externalAccessRefresh();

            // check for view mode first argument
            if (args[0].equals(ARG_TEMPLATE)) {
                browseBean.setDashboardView(true);
            }

            // the above calls into BrowseBean setup the NavigationHandler automatically
        } else {
            // perform the appropriate JSF navigation outcome
            NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
            navigationHandler.handleNavigation(fc, null, outcome);
        }
    } else if (OUTCOME_MYALFRESCO.equals(outcome)) {
        // setup the Dashboard Manager ready for the page we want to display
        if (req.getParameter(ARG_PAGE) != null) {
            DashboardManager manager = (DashboardManager) FacesHelper.getManagedBean(fc,
                    DashboardManager.BEAN_NAME);
            manager.getPageConfig().setCurrentPage(req.getParameter(ARG_PAGE));
        }

        // perform the appropriate JSF navigation outcome
        NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
        navigationHandler.handleNavigation(fc, null, outcome);
    } else if (OUTCOME_DIALOG.equals(outcome) || OUTCOME_WIZARD.equals(outcome)) {
        if (args.length != 0) {
            if (args.length > 1) {
                String currentNodeId = null;

                if (args[1].equals(WebDAVServlet.WEBDAV_PREFIX)) {
                    // Drop the first argument
                    String[] args2 = new String[args.length - 1];
                    for (int i = 1; i < args.length; i++) {
                        args2[i - 1] = args[i];

                        if (logger.isDebugEnabled()) {
                            logger.debug("Added segment " + args2[i - 1]);
                        }
                    }

                    NodeRef nodeRef = resolveWebDAVPath(fc, args2);
                    currentNodeId = nodeRef.getId();
                } else {
                    currentNodeId = args[1];
                }

                if (logger.isDebugEnabled()) {
                    logger.debug("currentNodeId: " + currentNodeId);
                }

                // if a GUID was passed, use it to init the NavigationBean current context
                NavigationBean navigator = (NavigationBean) FacesHelper.getManagedBean(fc,
                        NavigationBean.BEAN_NAME);
                navigator.setCurrentNodeId(currentNodeId);
                browseBean.setupSpaceAction(currentNodeId, true);

                // setup the Document on the browse bean
                // avoid java.lang.NullPointerException
                // at org.alfresco.web.bean.content.InviteContentUsersWizard.getPermissionsForType(InviteContentUsersWizard.java:49)
                // at org.alfresco.web.bean.wizard.BaseInviteUsersWizard.getRoles(BaseInviteUsersWizard.java:562)
                browseBean.setupContentAction(currentNodeId, true);
            }

            NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
            navigationHandler.handleNavigation(fc, null, outcome + ':' + args[0]);
        }
    } else if (OUTCOME_LOGOUT.equals(outcome)) {
        // special case for logout
        // invalidate ticket and clear the Security context for this thread
        Application.logOut(fc);
        res.sendRedirect(req.getContextPath() + FACES_SERVLET + Application.getLoginPage(getServletContext()));
        return;
    }

    // perform the forward to the page processed by the Faces servlet
    String viewId = fc.getViewRoot().getViewId();
    ViewSequenceUtils.nextViewSequence(fc);
    getServletContext().getRequestDispatcher(FACES_SERVLET + viewId).forward(req, res);
}

From source file:edu.ucla.stat.SOCR.chart.SuperYIntervalChartA.java

public void setDataTable(String input) {
    hasExample = true;//  www  .ja  v a 2 s.  co  m
    StringTokenizer lnTkns = new StringTokenizer(input, "#");
    String line;
    int rowCt = lnTkns.countTokens();
    resetTableRows(rowCt);
    resetTableColumns(3);
    int r = 0;
    while (lnTkns.hasMoreTokens()) {
        line = lnTkns.nextToken();

        //   String tb[] =line.split("\t");
        StringTokenizer cellTkns = new StringTokenizer(line, ";");// IE use "space" Mac use tab as cell separator
        int cellCnt = cellTkns.countTokens();
        String tb[] = new String[cellCnt];
        int r1 = 0;
        for (int i = 0; i < cellCnt; i++) {
            tb[r1] = cellTkns.nextToken();
            r1++;
        }
        for (int i = 0; i < tb.length; i++) {
            StringTokenizer cTkns = new StringTokenizer(tb[i], ",");
            int cCnt = cTkns.countTokens();
            String ctb[] = new String[cCnt];

            int r2 = 0;
            while (cTkns.hasMoreTokens()) {
                ctb[r2] = cTkns.nextToken();
                r2++;
            }
            for (int j = 0; j < ctb.length; j++) {
                dataTable.setValueAt(ctb[j], r, j + 1);
            }
        }
        r++;
    }

    // this will update the mapping panel     
    resetTableColumns(dataTable.getColumnCount());
}

From source file:info.magnolia.cms.taglibs.util.TextToImageTag.java

/**
 * Splits a string into words or characters, depending on the textSplit attribute. For words, spaces at either end
 * are removed./*from  w  ww.j a  va  2  s  .com*/
 * @param The string to split
 * @return An array of words
 */
private String[] getTextSubStrings(String text) {
    String[] subStrings = null;
    if (this.textSplit.equals(TEXT_SPLIT_CHARACTERS)) {
        subStrings = new String[text.length()];
        for (int i = 0; i < text.length(); i++) {
            subStrings[i] = text.substring(i, i + 1);
        }
    } else if (this.textSplit.equals(TEXT_SPLIT_WORDS)) {
        StringTokenizer st = new StringTokenizer(text, " "); // Split sentence into words
        subStrings = new String[st.countTokens()];
        for (int i = 0; st.hasMoreTokens(); i++) {
            subStrings[i] = st.nextToken().trim();
        }
    } else {
        subStrings = new String[] { text };
    }
    return subStrings;
}

From source file:dk.defxws.fgssolrremote.OperationsImpl.java

private void indexDoc(String pid, String repositoryName, String indexName, InputStream foxmlStream,
        StringBuffer resultXml, String indexDocXslt) throws java.rmi.RemoteException {
    String xsltName = indexDocXslt;
    String[] params = new String[12];
    int beginParams = indexDocXslt.indexOf("(");
    if (beginParams > -1) {
        xsltName = indexDocXslt.substring(0, beginParams).trim();
        int endParams = indexDocXslt.indexOf(")");
        if (endParams < beginParams)
            throw new GenericSearchException(
                    "Format error (no ending ')') in indexDocXslt=" + indexDocXslt + ": ");
        StringTokenizer st = new StringTokenizer(indexDocXslt.substring(beginParams + 1, endParams), ",");
        params = new String[12 + 2 * st.countTokens()];
        int i = 1;
        while (st.hasMoreTokens()) {
            String param = st.nextToken().trim();
            if (param == null || param.length() < 1)
                throw new GenericSearchException("Format error (empty param) in indexDocXslt=" + indexDocXslt
                        + " params[" + i + "]=" + param);
            int eq = param.indexOf("=");
            if (eq < 0)
                throw new GenericSearchException("Format error (no '=') in indexDocXslt=" + indexDocXslt
                        + " params[" + i + "]=" + param);
            String pname = param.substring(0, eq).trim();
            String pvalue = param.substring(eq + 1).trim();
            if (pname == null || pname.length() < 1)
                throw new GenericSearchException("Format error (no param name) in indexDocXslt=" + indexDocXslt
                        + " params[" + i + "]=" + param);
            if (pvalue == null || pvalue.length() < 1)
                throw new GenericSearchException("Format error (no param value) in indexDocXslt=" + indexDocXslt
                        + " params[" + i + "]=" + param);
            params[10 + 2 * i] = pname;/*w w  w.  j av a  2 s.  c o m*/
            params[11 + 2 * i++] = pvalue;
        }
    }
    params[0] = "REPOSITORYNAME";
    params[1] = repositoryName;
    params[2] = "FEDORASOAP";
    params[3] = config.getFedoraSoap(repositoryName);
    params[4] = "FEDORAUSER";
    params[5] = config.getFedoraUser(repositoryName);
    params[6] = "FEDORAPASS";
    params[7] = config.getFedoraPass(repositoryName);
    params[8] = "TRUSTSTOREPATH";
    params[9] = config.getTrustStorePath(repositoryName);
    params[10] = "TRUSTSTOREPASS";
    params[11] = config.getTrustStorePass(repositoryName);
    String xsltPath = config.getConfigName() + "/index/" + indexName + "/"
            + config.getUpdateIndexDocXslt(indexName, xsltName);
    StringBuffer sb = (new GTransformer()).transform(xsltPath, new StreamSource(foxmlStream),
            config.getURIResolver(indexName), params);
    if (logger.isDebugEnabled())
        logger.debug("indexDoc=\n" + sb.toString());
    if (sb.indexOf("</field>") > 0) { // skip if no fields
        try {
            sendToSolr("/update", sb.toString());
        } catch (Exception e) {
            throw new GenericSearchException("updateIndex sendToSolr:\n" + e, e);
        }
        if (indexDocExists(pid)) {
            updateTotal++;
            resultXml.append("<updated>" + pid + "</updated>\n");
        } else {
            insertTotal++;
            docCount++;
            resultXml.append("<inserted>" + pid + "</inserted>\n");
        }
        logger.info("IndexDocument=" + pid + " insertTotal=" + insertTotal + " updateTotal=" + updateTotal
                + " deleteTotal=" + deleteTotal + " emptyTotal=" + emptyTotal + " warnCount=" + warnCount
                + " docCount=" + docCount);
    } else {
        deletePid(pid, indexName, resultXml);
        logger.warn("IndexDocument " + pid + " does not contain any IndexFields!!! RepositoryName="
                + repositoryName + " IndexName=" + indexName);
        emptyTotal++;
    }
}

From source file:edu.ucla.stat.SOCR.chart.SuperBoxAndWhiskerChart_Vertical.java

/**
 * //w  ww .  ja  v a  2  s .com
 * @param in
 * @return
 */
protected List<Double> createValueList(String in) {
    vs = in;
    //   String[] values = in.split("( *)+,+( *)");
    //      int count = java.lang.reflect.Array.getLength(values);

    StringTokenizer st = new StringTokenizer(in, DELIMITERS);
    int count = st.countTokens();
    String[] values = new String[count];
    for (int i = 0; i < count; i++)
        values[i] = st.nextToken();

    //  System.out.println("count="+count);
    List<Double> result = new java.util.ArrayList<Double>();
    try {
        for (int i = 0; i < count; i++) {
            //System.out.println("values["+i+"]=*"+values[i]+"*");
            double v;
            if (values[i] != null && values[i].length() != 0 && !values[i].equals("null")) {
                v = Double.parseDouble(values[i]);
                result.add(new Double(v));
            }
        }
    } catch (NumberFormatException e) {
        showMessageDialog("Data format error!");
        return null;
    }
    return result;
}

From source file:org.elasticsoftware.elasterix.server.actors.User.java

@Override
public void onUndeliverable(ActorRef receiver, Object message) throws Exception {
    if (log.isDebugEnabled()) {
        log.debug(String.format("onUndeliverable. Message[%s]", message));
    }/*from   w w  w  .j  a v  a  2  s. c  om*/

    ActorRef sipService = getSystem().serviceActorFor("sipService");
    if (message instanceof SipRequestMessage) {
        SipRequestMessage m = (SipRequestMessage) message;
        switch (m.getSipMethod()) {
        case INVITE:
            if (log.isDebugEnabled()) {
                log.debug(String.format("onUndeliverable. UAC[%s] does not exist", receiver.getActorId()));
            }

            if (STRICT_UAC) {
                sipService.tell(
                        m.toSipResponseMessage(SipResponseStatus.GONE
                                .setOptionalMessage(String.format("UAC[%s] not found", receiver.getActorId()))),
                        getSelf());
            } else {
                // create UAC and resent message
                StringTokenizer st = new StringTokenizer(receiver.getActorId(), "/_", false);
                if (st.countTokens() == 4) {
                    st.nextToken(); // skip "uac"
                    UserAgentClient.State state = new UserAgentClient.State(st.nextToken(), st.nextToken(),
                            Integer.parseInt(st.nextToken()));
                    ActorRef ref = getSystem().actorOf(receiver.getActorId(), UserAgentClient.class, state);
                    ref.tell(message, getSelf());
                }
            }
        }
    }
}