Example usage for java.lang StringBuilder replace

List of usage examples for java.lang StringBuilder replace

Introduction

In this page you can find the example usage for java.lang StringBuilder replace.

Prototype

@Override
public StringBuilder replace(int start, int end, String str) 

Source Link

Usage

From source file:edu.harvard.i2b2.workplace.dao.FolderDao.java

/**
 * This method is to set protected access on a file/folder in workplace
 * It first checks if user has correct privileges to the file, that is
 * either he she is manager or the file is shared or the file belongs
 * to him/her. The it searches for all the folders under the given 
 * index. if folders are found then it runs the update query atleast
 * 3 times to update the root folder in workplace_access table, all the
 * child folders in workplace table and all the child content in workplace
 * table.  //from  w w w. java2 s . c om
 * 
 * @param requestType
 * @param projectInfo
 * @param dbInfo
 * @param userId
 * @return
 * @throws I2B2DAOException
 * @throws I2B2Exception
 * 
 * @author Neha Patel
 */
public int setProtectedAccess(final ProtectedType requestType, final ProjectType projectInfo,
        final DBInfoType dbInfo, String userId) throws I2B2DAOException, I2B2Exception {

    boolean settingRoot = false;
    int numRowsSet = -1;
    int numParentUpdated = -1;
    int numWorkAccUpdated = -1;
    String sharedStr = "";
    String contentUserId = "";
    String tableName = "";
    boolean managerRole = false;
    boolean isFolder = true;

    String metadataSchema = dbInfo.getDb_fullSchema();
    setDataSource(dbInfo.getDb_dataSource());

    if (projectInfo.getRole().size() == 0) {
        log.error("no role found for this user in project: " + projectInfo.getName());
        I2B2Exception e = new I2B2Exception("No role found for user");
        throw e;
    }

    // Check if user is a manager
    for (String param : projectInfo.getRole()) {
        if (param.equalsIgnoreCase("manager")) {
            managerRole = true;
            break;
        }
    }

    ParameterizedRowMapper<String> map = new ParameterizedRowMapper<String>() {
        public String mapRow(ResultSet rs, int rowNum) throws SQLException {

            String resultRow = "\\tablename=" + rs.getString("c_table_name") + "\\share_id="
                    + rs.getString("c_share_id") + "\\user_id=" + rs.getString("c_user_id");

            return resultRow;
        }
    };

    //extract table code and index
    String tableCd = StringUtil.getTableCd(requestType.getIndex());
    String index = StringUtil.getIndex(requestType.getIndex());

    List resultString = null;
    StringBuilder sqlToRetrieveTableName = new StringBuilder(
            "select distinct c_table_name, c_share_id, c_user_id from " + metadataSchema
                    + "workplace_access where LOWER(c_group_id) = ?");

    // Check if the user is setting access for root directory
    // by looking for index in the current table
    try {
        sqlToRetrieveTableName.append(" and c_index = ? ");
        resultString = jt.query(sqlToRetrieveTableName.toString(), map, projectInfo.getId().toLowerCase(),
                index);
    } catch (DataAccessException e) {
        log.error(e.getMessage());
        throw new I2B2DAOException("Database Error");
    }

    String resultToSplit = "";
    // if the above query returned any result
    // that means user was setting access for root directory
    if (resultString != null && !resultString.isEmpty()) {

        settingRoot = true;
        isFolder = true;

        // getting tablename, share_id, user_id from the result string
        resultToSplit = (String) resultString.get(0);
        int indexofShared = resultToSplit.indexOf("\\share_id=");
        int indexofUser = resultToSplit.indexOf("\\user_id=");
        tableName = resultToSplit.substring(11, indexofShared);

        // if its not manager check if the file/folder is shared
        // if not shared either, then verify that user is setting
        // privilege for his/her file/folder
        if (managerRole == false) {
            sharedStr = resultToSplit.substring(indexofShared + 10, indexofUser);
            contentUserId = resultToSplit.substring(indexofUser + 9);

            if (!sharedStr.equalsIgnoreCase("Y")) {
                if (!contentUserId.equalsIgnoreCase(userId)) {
                    log.debug("User does not have privileges to set protected access for this content");
                    return -11111;
                }
            } // if (sharedStr==null || !sharedStr.equalsIgnoreCase("Y"))
        } // if managerRole == false
    } //if(resultString!=null && !resultString.isEmpty())         
      // query result is null that means item doesn't exist in workplace_access table
      // or user is not setting access for root directory
      // Get tablename using the tablecd given as part of indexString in the request
    else if (resultString == null || resultString.isEmpty()) {

        // replace the last condition of 'and c_index=?' with 'and c_table_cd'
        sqlToRetrieveTableName.replace(sqlToRetrieveTableName.lastIndexOf("and"),
                sqlToRetrieveTableName.length() - 1, " and LOWER(c_table_cd) = ? ");

        try {
            resultString = jt.query(sqlToRetrieveTableName.toString(), map, projectInfo.getId().toLowerCase(),
                    tableCd.toLowerCase());
        } catch (DataAccessException e) {
            log.error(e.getMessage());
            throw new I2B2DAOException("Database Error");
        }

        resultToSplit = (String) resultString.get(0);

        // getting tablename from the query result
        tableName = resultToSplit.substring(11, resultToSplit.indexOf("\\share_id="));

        List result;
        ParameterizedRowMapper<String> mapTocheckAccess = new ParameterizedRowMapper<String>() {
            public String mapRow(ResultSet rs, int rowNum) throws SQLException {

                String resultRow = "\\share_id=" + rs.getString("c_share_id") + "\\user_id="
                        + rs.getString("c_user_id") + "\\type=" + rs.getString("c_work_xml_i2b2_type");

                return resultRow;
            }
        };

        // Run query in table workplace to find out if the content is shared or does it belong to user
        // Also find the type of the file
        String sql = "select  c_share_id, c_user_id, c_work_xml_i2b2_type from " + metadataSchema + tableName
                + " where c_index = ? and LOWER(c_group_id) = ?";
        try {
            result = jt.query(sql, mapTocheckAccess, index, projectInfo.getId().toLowerCase());
        } catch (DataAccessException e) {
            log.error(e.getMessage());
            throw new I2B2DAOException("Database Error");
        }

        // get the user id and share_id from result string
        resultToSplit = (String) result.get(0);
        String type = resultToSplit.substring(resultToSplit.lastIndexOf("\\") + 6);

        if (!type.equalsIgnoreCase("FOLDER")) {
            isFolder = false;
        } else
            isFolder = true;

        // if user is not a manager
        // then check if file/folder is shared
        // if not shared then verify file/folder belongs to user
        if (managerRole == false) {

            sharedStr = resultToSplit.substring(10, resultToSplit.indexOf("\\user_id="));
            contentUserId = resultToSplit.substring(resultToSplit.indexOf("\\user_id=") + 9,
                    resultToSplit.lastIndexOf("\\"));

            if (sharedStr != null && !sharedStr.equalsIgnoreCase("Y")) {
                if (!contentUserId.equalsIgnoreCase(userId)) {
                    log.debug("User does not have privileges to set protected access for this content");
                    return -11111;
                }
            } // if (sharedStr==null || !sharedStr.equalsIgnoreCase("Y"))
        } // if managerRole == false      
    }

    StringBuilder indexStr = new StringBuilder();
    String protectedAccVal = "";

    if (requestType.getProtectedAccess().trim().equalsIgnoreCase("true"))
        protectedAccVal = "Y";
    else
        protectedAccVal = "N";

    ArrayList<String> parentIdxList = new ArrayList<String>();
    parentIdxList.add(index);
    indexStr.append("'" + index + "'");

    // if initial request was for a folder only
    // then run this part 
    if (isFolder) {

        List resultingIndx;
        ParameterizedRowMapper<String> mapForIndexes = new ParameterizedRowMapper<String>() {
            public String mapRow(ResultSet rs, int rowNum) throws SQLException {
                String name = (rs.getString("c_index"));
                return name;
            }
        };

        // Get all the parent indexes (folder indexes under the top level directory)
        // and store it in an arraylist
        String parentIdx = "";
        for (int i = 0; i < parentIdxList.size(); i++) {
            try {
                parentIdx = parentIdxList.get(i);
                if (i > 0) {
                    indexStr.append(", '" + parentIdx + "'");
                }
                String sqlToCollectIndex = "select c_index from " + metadataSchema + tableName
                        + " where c_parent_index = ? and LOWER(c_group_id) = ? and c_work_xml_i2b2_type = 'FOLDER'";
                resultingIndx = jt.query(sqlToCollectIndex, mapForIndexes, parentIdx,
                        projectInfo.getId().toLowerCase());
            } catch (DataAccessException e) {
                log.error(e.getMessage());
                throw new I2B2DAOException("Database Error");
            }
            if (resultingIndx != null)
                parentIdxList.addAll(resultingIndx);
        }

        // set the protected access for all the content found under the 
        // parent indexes stored in the arraylist
        numParentUpdated = updateProtectedAccess(metadataSchema, tableName, "c_parent_index",
                indexStr.toString(), protectedAccVal);
    }

    if (settingRoot) {
        // set the protected access for root directory which is in workplace_access table
        numWorkAccUpdated = updateProtectedAccess(metadataSchema, "workplace_access", "c_index",
                indexStr.toString(), protectedAccVal);
    }

    // If setting root folder, then set all the folders to protected access
    // if setting one item then still use the same query to set that item to protected_access
    numRowsSet = updateProtectedAccess(metadataSchema, tableName, "c_index", indexStr.toString(),
            protectedAccVal);

    // Return the correct number of updated rows 
    if (isFolder)
        numRowsSet += numParentUpdated;

    if (settingRoot)
        numRowsSet += numWorkAccUpdated;

    return numRowsSet;
}

From source file:ffx.potential.parsers.PDBFilter.java

private void writeSIFTAtom(Atom atom, int serial, StringBuilder sb, StringBuilder anisouSB, BufferedWriter bw,
        String siftScore) throws IOException {
    String name = atom.getName();
    if (name.length() > 4) {
        name = name.substring(0, 4);//w  ww  . j  a  v a  2  s  .c  o  m
    } else if (name.length() == 1) {
        name = name + "  ";
    } else if (name.length() == 2) {
        if (atom.getAtomType().valence == 0) {
            name = name + "  ";
        } else {
            name = name + " ";
        }
    }
    double xyz[] = vdwH ? atom.getRedXYZ() : atom.getXYZ(null);
    if (nSymOp != 0) {
        Crystal crystal = activeMolecularAssembly.getCrystal();
        SymOp symOp = crystal.spaceGroup.getSymOp(nSymOp);
        double[] newXYZ = new double[xyz.length];
        crystal.applySymOp(xyz, newXYZ, symOp);
        xyz = newXYZ;
    }
    sb.replace(6, 16, String.format("%5s " + padLeft(name.toUpperCase(), 4), Hybrid36.encode(5, serial)));
    Character altLoc = atom.getAltLoc();
    if (altLoc != null) {
        sb.setCharAt(16, altLoc);
    } else {
        sb.setCharAt(16, ' ');
    }
    if (siftScore == null) {
        sb.replace(30, 66,
                String.format("%8.3f%8.3f%8.3f%6.2f%6.2f", xyz[0], xyz[1], xyz[2], atom.getOccupancy(), 110.0));
    } else {
        sb.replace(30, 66, String.format("%8.3f%8.3f%8.3f%6.2f%6.2f", xyz[0], xyz[1], xyz[2],
                atom.getOccupancy(), (1 + (-1 * Float.parseFloat(siftScore))) * 100));
    }
    name = Atom.ElementSymbol.values()[atom.getAtomicNumber() - 1].toString();
    name = name.toUpperCase();
    if (atom.isDeuterium()) {
        name = "D";
    }
    sb.replace(76, 78, padLeft(name, 2));
    sb.replace(78, 80, String.format("%2d", 0));
    if (!listMode) {
        bw.write(sb.toString());
        bw.newLine();
    } else {
        listOutput.add(sb.toString());
    }
    // =============================================================================
    //  1 - 6        Record name   "ANISOU"
    //  7 - 11       Integer       serial         Atom serial number.
    // 13 - 16       Atom          name           Atom name.
    // 17            Character     altLoc         Alternate location indicator
    // 18 - 20       Residue name  resName        Residue name.
    // 22            Character     chainID        Chain identifier.
    // 23 - 26       Integer       resSeq         Residue sequence number.
    // 27            AChar         iCode          Insertion code.
    // 29 - 35       Integer       u[0][0]        U(1,1)
    // 36 - 42       Integer       u[1][1]        U(2,2)
    // 43 - 49       Integer       u[2][2]        U(3,3)
    // 50 - 56       Integer       u[0][1]        U(1,2)
    // 57 - 63       Integer       u[0][2]        U(1,3)
    // 64 - 70       Integer       u[1][2]        U(2,3)
    // 77 - 78       LString(2)    element        Element symbol, right-justified.
    // 79 - 80       LString(2)    charge         Charge on the atom.
    // =============================================================================
    double[] anisou = atom.getAnisou(null);
    if (anisou != null) {
        anisouSB.replace(6, 80, sb.substring(6, 80));
        anisouSB.replace(28, 70,
                String.format("%7d%7d%7d%7d%7d%7d", (int) (anisou[0] * 1e4), (int) (anisou[1] * 1e4),
                        (int) (anisou[2] * 1e4), (int) (anisou[3] * 1e4), (int) (anisou[4] * 1e4),
                        (int) (anisou[5] * 1e4)));
        if (!listMode) {
            bw.write(anisouSB.toString());
            bw.newLine();
        } else {
            listOutput.add(anisouSB.toString());
        }
    }
}

From source file:org.apache.openjpa.jdbc.sql.DBDictionary.java

/**
 * Remove vowels from the specified StringBuilder.
 *
 * @return true if any vowels have been removed
 *//*  w  ww . j  a  v  a 2s .com*/
private static boolean stripVowel(StringBuilder name) {
    if (name == null || name.length() == 0)
        return false;

    char[] vowels = { 'A', 'E', 'I', 'O', 'U', };
    for (int i = 0; i < vowels.length; i++) {
        int index = name.toString().toUpperCase().indexOf(vowels[i]);
        if (index != -1) {
            name.replace(index, index + 1, "");
            return true;
        }
    }
    return false;
}

From source file:ffx.potential.parsers.PDBFilter.java

/**
 * <p>/*from   w  w  w .  j  a  v  a 2 s.c  o  m*/
 * writeAtom</p>
 *
 * @param atom a {@link ffx.potential.bonded.Atom} object.
 * @param serial a int.
 * @param sb a {@link java.lang.StringBuilder} object.
 * @param anisouSB a {@link java.lang.StringBuilder} object.
 * @param bw a {@link java.io.BufferedWriter} object.
 * @throws java.io.IOException if any.
 */
private void writeAtom(Atom atom, int serial, StringBuilder sb, StringBuilder anisouSB, BufferedWriter bw)
        throws IOException {
    if (ignoreUnusedAtoms && !atom.getUse()) {
        return;
    }
    String name = atom.getName();
    if (name.length() > 4) {
        name = name.substring(0, 4);
    } else if (name.length() == 1) {
        name = name + "  ";
    } else if (name.length() == 2) {
        if (atom.getAtomType().valence == 0) {
            name = name + "  ";
        } else {
            name = name + " ";
        }
    }
    double xyz[] = vdwH ? atom.getRedXYZ() : atom.getXYZ(null);
    if (nSymOp != 0) {
        Crystal crystal = activeMolecularAssembly.getCrystal();
        SymOp symOp = crystal.spaceGroup.getSymOp(nSymOp);
        double[] newXYZ = new double[xyz.length];
        crystal.applySymOp(xyz, newXYZ, symOp);
        xyz = newXYZ;
    }
    sb.replace(6, 16, String.format("%5s " + padLeft(name.toUpperCase(), 4), Hybrid36.encode(5, serial)));
    Character altLoc = atom.getAltLoc();
    if (altLoc != null) {
        sb.setCharAt(16, altLoc);
    } else {
        sb.setCharAt(16, ' ');
    }

    /*sb.replace(30, 66, String.format("%8.3f%8.3f%8.3f%6.2f%6.2f",
        xyz[0], xyz[1], xyz[2], atom.getOccupancy(), atom.getTempFactor()));*/

    /**
     * On the following code:
     * #1: StringBuilder.replace will allow for longer strings, expanding the
     * StringBuilder's length if necessary.
     * #2: sb was never re-initialized, so if there was overflow, sb would
     * continue to be > 80 characters long, resulting in broken PDB files
     * #3: It may be wiser to have XYZ coordinates result in shutdown, not
     * truncation of coordinates.
     * #4: Excessive B-factors aren't much of an issue; if the B-factor is
     * past 999.99, that's the difference between "density extends to Venus"
     * and "density extends to Pluto".
     */

    StringBuilder decimals = new StringBuilder();
    for (int i = 0; i < 3; i++) {
        try {
            decimals.append(StringUtils.fwFpDec(xyz[i], 8, 3));
        } catch (IllegalArgumentException ex) {
            String newValue = StringUtils.fwFpTrunc(xyz[i], 8, 3);
            logger.info(String.format(" XYZ %d coordinate %8.3f for atom %s "
                    + "overflowed bounds of 8.3f string specified by PDB " + "format; truncating value to %s",
                    i, xyz[i], atom.toString(), newValue));
            decimals.append(newValue);
        }
    }
    try {
        decimals.append(StringUtils.fwFpDec(atom.getOccupancy(), 6, 2));
    } catch (IllegalArgumentException ex) {
        logger.severe(
                String.format(" Occupancy %f for atom %s is impossible; " + "value must be between 0 and 1",
                        atom.getOccupancy(), atom.toString()));
    }
    try {
        decimals.append(StringUtils.fwFpDec(atom.getTempFactor(), 6, 2));
    } catch (IllegalArgumentException ex) {
        String newValue = StringUtils.fwFpTrunc(atom.getTempFactor(), 6, 2);
        logger.info(String.format(
                " Atom temp factor %6.2f for atom %s overflowed "
                        + "bounds of 6.2f string specified by PDB format; truncating " + "value to %s",
                atom.getTempFactor(), atom.toString(), newValue));
        decimals.append(newValue);
    }
    sb.replace(30, 66, decimals.toString());

    name = Atom.ElementSymbol.values()[atom.getAtomicNumber() - 1].toString();
    name = name.toUpperCase();
    if (atom.isDeuterium()) {
        name = "D";
    }
    sb.replace(76, 78, padLeft(name, 2));
    sb.replace(78, 80, String.format("%2d", 0));
    if (!listMode) {
        bw.write(sb.toString());
        bw.newLine();
    } else {
        listOutput.add(sb.toString());
    }
    // =============================================================================
    //  1 - 6        Record name   "ANISOU"
    //  7 - 11       Integer       serial         Atom serial number.
    // 13 - 16       Atom          name           Atom name.
    // 17            Character     altLoc         Alternate location indicator
    // 18 - 20       Residue name  resName        Residue name.
    // 22            Character     chainID        Chain identifier.
    // 23 - 26       Integer       resSeq         Residue sequence number.
    // 27            AChar         iCode          Insertion code.
    // 29 - 35       Integer       u[0][0]        U(1,1)
    // 36 - 42       Integer       u[1][1]        U(2,2)
    // 43 - 49       Integer       u[2][2]        U(3,3)
    // 50 - 56       Integer       u[0][1]        U(1,2)
    // 57 - 63       Integer       u[0][2]        U(1,3)
    // 64 - 70       Integer       u[1][2]        U(2,3)
    // 77 - 78       LString(2)    element        Element symbol, right-justified.
    // 79 - 80       LString(2)    charge         Charge on the atom.
    // =============================================================================
    double[] anisou = atom.getAnisou(null);
    if (anisou != null) {
        anisouSB.replace(6, 80, sb.substring(6, 80));
        anisouSB.replace(28, 70,
                String.format("%7d%7d%7d%7d%7d%7d", (int) (anisou[0] * 1e4), (int) (anisou[1] * 1e4),
                        (int) (anisou[2] * 1e4), (int) (anisou[3] * 1e4), (int) (anisou[4] * 1e4),
                        (int) (anisou[5] * 1e4)));
        if (!listMode) {
            bw.write(anisouSB.toString());
            bw.newLine();
        } else {
            listOutput.add(anisouSB.toString());
        }
    }
}

From source file:com.arksoft.epamms.ZGlobal1_Operation.java

public int zTrim(StringBuilder stringStringInOut) {
    String s = StringUtils.trim(stringStringInOut.toString());
    stringStringInOut.replace(0, stringStringInOut.length(), s);
    return 0;//from  w ww . j a  v a 2s  .co  m
}

From source file:org.infoglue.deliver.invokers.PageInvoker.java

protected String decorateHeadAndPageWithVarsFromComponents(String pageString) {

    pageString = this.getTemplateController().decoratePage(pageString);

    StringBuilder sb = null;
    Timer t = new Timer();
    this.generateExtensionBundles(
            this.getTemplateController().getDeliveryContext().getScriptExtensionHeadBundles(),
            "text/javascript", "head");
    this.generateExtensionBundles(
            this.getTemplateController().getDeliveryContext().getScriptExtensionBodyBundles(),
            "text/javascript", "body");
    this.generateExtensionBundles(this.getTemplateController().getDeliveryContext().getCSSExtensionBundles(),
            "text/css", "head");

    List htmlHeadItems = this.getTemplateController().getDeliveryContext().getHtmlHeadItems();
    if (htmlHeadItems != null && htmlHeadItems.size() > 0) {
        int indexOfHeadEndTag = pageString.indexOf("</head");
        if (indexOfHeadEndTag == -1)
            indexOfHeadEndTag = pageString.indexOf("</HEAD");

        if (indexOfHeadEndTag != -1) {
            sb = new StringBuilder(pageString);
            String headerItems = "";
            Iterator htmlHeadItemsIterator = htmlHeadItems.iterator();
            while (htmlHeadItemsIterator.hasNext()) {
                String value = (String) htmlHeadItemsIterator.next();
                //logger.info("headItem:" + value);
                headerItems = headerItems + value + "\n";
            }//from   w  ww.  j a va 2s .  c o m
            sb.insert(indexOfHeadEndTag, headerItems);
            //pageString = sb.toString();
        }
    }

    List<String> htmlBodyEndItems = this.getTemplateController().getDeliveryContext().getHtmlBodyEndItems();
    if (htmlBodyEndItems != null && htmlBodyEndItems.size() > 0) {
        if (sb == null)
            sb = new StringBuilder(pageString);

        int indexOfBodyEndTag = sb.indexOf("</body");
        if (indexOfBodyEndTag == -1)
            indexOfBodyEndTag = sb.indexOf("</BODY");

        if (indexOfBodyEndTag != -1) {
            String bodyItems = "";
            Iterator htmlBodyItemsIterator = htmlBodyEndItems.iterator();
            while (htmlBodyItemsIterator.hasNext()) {
                String value = (String) htmlBodyItemsIterator.next();
                //logger.info("headItem:" + value);
                bodyItems = bodyItems + value + "\n";
            }
            sb.insert(indexOfBodyEndTag, bodyItems);
            //pageString = sb.toString();
        }
    }
    RequestAnalyser.getRequestAnalyser().registerComponentStatistics("pageInvoker", t.getElapsedTime());

    try {
        int lastModifiedDateTimeIndex;
        if (sb == null)
            lastModifiedDateTimeIndex = pageString.indexOf("<ig:lastModifiedDateTime");
        else
            lastModifiedDateTimeIndex = sb.indexOf("<ig:lastModifiedDateTime");

        //logger.info("OOOOOOOOOOOOO lastModifiedDateTimeIndex:" + lastModifiedDateTimeIndex);
        if (lastModifiedDateTimeIndex > -1) {
            if (sb == null)
                sb = new StringBuilder(pageString);

            int lastModifiedDateTimeEndIndex = sb.indexOf("</ig:lastModifiedDateTime>",
                    lastModifiedDateTimeIndex);

            String tagInfo = sb.substring(lastModifiedDateTimeIndex, lastModifiedDateTimeEndIndex);
            //logger.info("tagInfo:" + tagInfo);
            String dateFormat = "yyyy-MM-dd HH:mm";
            int formatStartIndex = tagInfo.indexOf("format");
            if (formatStartIndex > -1) {
                int formatEndIndex = tagInfo.indexOf("\"", formatStartIndex + 8);
                if (formatEndIndex > -1)
                    dateFormat = tagInfo.substring(formatStartIndex + 8, formatEndIndex);
            }
            //logger.info("dateFormat:" + dateFormat);

            String dateString = vf.formatDate(
                    this.getTemplateController().getDeliveryContext().getLastModifiedDateTime(),
                    this.getTemplateController().getLocale(), dateFormat);
            //logger.info("dateString:" + dateString);
            sb.replace(lastModifiedDateTimeIndex,
                    lastModifiedDateTimeEndIndex + "</ig:lastModifiedDateTime>".length(), dateString);
            //logger.info("Replaced:" + lastModifiedDateTimeIndex + " to " + lastModifiedDateTimeEndIndex + "</ig:lastModifiedDateTime>".length() + " with " + dateString);
        }
    } catch (Exception e) {
        logger.error("Problem setting lastModifiedDateTime:" + e.getMessage(), e);
    }

    if (sb != null)
        pageString = sb.toString();

    return pageString;
}

From source file:com.arksoft.epamms.ZGlobal1_Operation.java

/**
   ////////////////////////////////////////////////////////////////////////////////////////////////////
   ////from  w w w  . ja v  a  2s  .c om
   //  Method Name: GetDataTypeForAttribute
   //
   //    Return the Data Type for an attribute
   //
   ////////////////////////////////////////////////////////////////////////////////////////////////////
   public int
   GetDataTypeForAttribute( String stringDataType,
                    View   lpView,
                    String entityName,
                    String attributeName )
   {
      LPVIEWENTITY lpEntityDef;
      LPVIEWATTRIB lpAttributeDef;
      int nRC;
        
      lpEntityDef = String zGETPTR( MiGetEntityDefForView( lpView, entityName ) );
      if ( lpEntityDef == 0 )
 return -16;
        
      // Position on attribute.
   #ifdef VIEWENTITY_OD
      lpAttributeDef = String zGETPTR( lpEntityDef->hFirstOD_Attrib );
      nRC = 1;
      while ( lpAttributeDef > 0 && nRC > 0 )
      {
 if ( zstrcmp( lpAttributeDef->stringName, attributeName ) == 0 )
    nRC = 0;
        
 if ( nRC > 0 )
    lpAttributeDef = String zGETPTR( lpAttributeDef->hNextOD_Attrib );
      }
   #else
      lpAttributeDef = String zGETPTR( lpEntityDef->hFirstAttributeDef );
      nRC = 1;
      while ( lpAttributeDef > 0 && nRC > 0 )
      {
 if ( zstrcmp( lpAttributeDef->stringName, attributeName ) == 0 )
    nRC = 0;
        
 if ( nRC > 0 )
    lpAttributeDef = String zGETPTR( lpAttributeDef->hNextAttributeDef );
      }
   #endif
      if ( nRC > 0 )
      {
 MessageSend( lpView, "", "GetDataTypeForAttribute",
              "The attribute specified was not found.",
              zMSGQ_OBJECT_CONSTRAINT_ERROR, 0 );
 return -1;
      }
        
      // Set single character datatype followed by a string terminator.
      *stringDataType = lpAttributeDef->hDomain->cType;
      *(stringDataType + 1) = 0;
        
      return 0;
   } // GetDataTypeForAttribute
**/

//
int ParseOutEntityAttribute(String entityDotAttribute, StringBuilder entityName, StringBuilder attributeName) {
    int k;
    int lSkipLth;

    // Initialize entityName and attributeName.
    entityName.replace(0, -1, entityDotAttribute);
    attributeName.delete(0, -1);
    // entityDotAttribute is pointing to the first character of the entity name on entry to this routine.
    // Parse out Entity Name

    for (k = 0; k < entityName.length(); k++) {
        char ch = entityName.charAt(k);
        if (ch == '.' || ch == ']' || ch == '}') {
            entityName.setCharAt(k, '\0');
            if (ch == '}')
                return -2;

            if (ch != ']') // there is an attribute, so keep going
            {
                int j = 0;
                k++;

                // Parse out Attribute Name
                ch = entityDotAttribute.charAt(k);
                while (ch != ']' && ch != '}') {
                    if (ch == '}')
                        return -2;

                    attributeName.setCharAt(j, ch);
                    j++;
                    k++;
                    ch = entityDotAttribute.charAt(k);
                }

                attributeName.setCharAt(k, '\0');
            }
        }
    }

    lSkipLth = k + 1; // TODO not sure this translation to java is exactly right for SkipLth
    return lSkipLth;
}

From source file:com.quinsoft.noa.ZGLOBAL1_Operation.java

public int zTrim(StringBuilder stringStringInOut) {
    String s = stringStringInOut.toString().trim();
    stringStringInOut.replace(0, -1, s);
    return 0;/*from ww  w  .  j a va2s. co  m*/
}