Example usage for java.lang StringBuffer indexOf

List of usage examples for java.lang StringBuffer indexOf

Introduction

In this page you can find the example usage for java.lang StringBuffer indexOf.

Prototype

@Override
public int indexOf(String str) 

Source Link

Usage

From source file:padl.creator.javafile.eclipse.util.PadlParserUtil.java

/**
 * Get or create a ghost entity/*  ww w  . j ava 2  s  .c  o m*/
 * 
 * @param isDealingWithExtend
 * @param anEntityTypeBinding
 * @param aPadlModel
 * @param aCurrentPackagePath
 * @return
 */
private static IFirstClassEntity getOrCreateGhostEntity(final boolean isDealingWithExtend,
        final ITypeBinding anEntityTypeBinding, final ICodeLevelModel aPadlModel,
        final String aCurrentPackagePath) {

    final StringBuffer tmpStringBuffer = new StringBuffer();
    String ghostName = null;
    String ghostPackagePath = null;
    String fullyQualifiedName = null;
    final String entityBindingKey = anEntityTypeBinding.getKey();
    final String prefix = "Recovered#currentType";

    if (entityBindingKey.startsWith(prefix)) {
        // ghosts in existing entities
        tmpStringBuffer.append(entityBindingKey.substring(prefix.length()));
        tmpStringBuffer.deleteCharAt(tmpStringBuffer.length() - 1);

        // Yann 2015/03/16: Symbols collision with IConstants!
        // I make sure that the name of the entity does not contain
        // any symbol used in the models, see IConstants, because
        // the entityBindingKey will be of the form:
        //   org.hibernate.envers.entities.mapper.relation.lazy.initializor.Initializor<List<U>>0<Ljava/util/List<Lorg/hibernate/envers/entities/mapper/relation/lazy/proxy/C:\Data\Java Programs\hibernate-orm-3.6.4.Final\hibernate-envers\src\main\java\org\hibernate\envers\entities\mapper\relation\lazy\proxy\ListProxy~ListProxy;:TU;>;>
        if (entityBindingKey.indexOf('/') > -1 || entityBindingKey.indexOf('\\') > -1) {

            ghostName = tmpStringBuffer.substring(0, tmpStringBuffer.indexOf("0"));
        } else {
            ghostName = tmpStringBuffer.toString();
        }
        ghostPackagePath = anEntityTypeBinding.getPackage().getName();
    } else if (isDealingWithExtend && entityBindingKey.startsWith("Recovered#typeBinding")) {

        ghostName = anEntityTypeBinding.getQualifiedName();
        ghostPackagePath = anEntityTypeBinding.getPackage().getName();
    } else {
        // Pure ghosts
        // Fix for eclipse_12-15-2009 (fixed) case of generic types
        // (templates) (fixed)
        final String[] packageComponents;
        if (anEntityTypeBinding.getPackage() == null) {// case of templates
            packageComponents = new String[0];
            // should be deleted (only for debug purpose)
            /*
             * Output .getInstance() .normalOutput() .println(
             * "PadlParserUtil in getOrCreateGhostEntity anEntityTypeBinding.getPackage() == null "
             * + anEntityTypeBinding .getQualifiedName());
             */
        } else {
            packageComponents = anEntityTypeBinding.getPackage().getNameComponents();
        }

        final int numberOfNames = packageComponents.length;

        char firstLetter;
        int i = 0;
        boolean checkPackage = true;

        if (numberOfNames > 0) {
            firstLetter = packageComponents[0].toCharArray()[0];
            if (Character.isLowerCase(firstLetter)) {
                tmpStringBuffer.append(packageComponents[0]);
                i++;
            } else {
                checkPackage = false;
            }

            while (i < numberOfNames && checkPackage) {
                firstLetter = packageComponents[i].toCharArray()[0];
                if (Character.isLowerCase(firstLetter)) {
                    tmpStringBuffer.append('.');
                    tmpStringBuffer.append(packageComponents[i]);
                    i++;
                } else {
                    checkPackage = false;
                }
            }
        }

        ghostPackagePath = tmpStringBuffer.toString();
        // why? aCurrentPackagePath=display path, is it more than the
        // package???
        String packagePath = aCurrentPackagePath;
        if (aCurrentPackagePath.length() > 2) {
            /*
             * Output .getInstance() .normalOutput() .println(
             * "PadlParserUtil in getOrCreateGhostEntity aCurrentPackagePath.length() > 2 "
             * + aCurrentPackagePath.length());
             */
            packagePath = aCurrentPackagePath.substring(aCurrentPackagePath.indexOf('|') + 1).replace("|", ".");
        }

        // if package ghost is the same with the current package and this
        // ghost is not from source
        // this means generally that there is a probleme of resolving so we
        // put this ghost in a specific package
        // also when this ghost is a generic type, we do the same
        // These conditions are not always true but permit to handle a lot
        // of cases
        if ((ghostPackagePath.equals(packagePath) || ghostPackagePath.length() == 0
                && ArrayUtils.isEquals(packagePath.toCharArray(), Constants.DEFAULT_PACKAGE_ID))
                && !anEntityTypeBinding.isFromSource()
                || ghostPackagePath.length() == 0 && anEntityTypeBinding.isFromSource()
                        && anEntityTypeBinding.isTypeVariable()) {
            ghostPackagePath = "unknown.ghost.packag";
        }

        tmpStringBuffer.setLength(0);

        while (i < numberOfNames) {
            tmpStringBuffer.append(packageComponents[i]);
            tmpStringBuffer.append('.');

            i++;
        }

        tmpStringBuffer.append(anEntityTypeBinding.getName());
        ghostName = tmpStringBuffer.toString();

    }

    tmpStringBuffer.setLength(0);
    tmpStringBuffer.append(ghostPackagePath);
    if (tmpStringBuffer.length() != 0) {
        tmpStringBuffer.append('.');
    }
    tmpStringBuffer.append(ghostName);
    fullyQualifiedName = tmpStringBuffer.toString();

    final int indexOfDot = ghostName.lastIndexOf('.');

    if (indexOfDot < 0) {
        // Case of a ghost
        IFirstClassEntity ghost = aPadlModel.getTopLevelEntityFromID(fullyQualifiedName.toCharArray());
        if (ghost == null) {
            ghost = PadlParserUtil.createGhost(aPadlModel, fullyQualifiedName.toCharArray());
        }
        return ghost;
    } else {
        // case of a ghost member
        // get or create a ghost based on the package name and the ghostName
        final String searchedGhostID = PadlParserUtil.renameWith$(fullyQualifiedName, ghostPackagePath);

        StringTokenizer tokenizer;

        //   int nbTokens = tokenizer.countTokens(); // number of entities in the
        // hierarchy=class>memberClass1>MemberClass2

        tokenizer = new StringTokenizer(searchedGhostID, "$");

        IPackage searchedPackage = null;

        IFirstClassEntity currentEntity = null;
        final String currentEntityID = tokenizer.nextToken();

        searchedPackage = PadlParserUtil.getPackage(ghostPackagePath, aPadlModel);

        if (searchedPackage != null) {
            currentEntity = aPadlModel.getTopLevelEntityFromID(currentEntityID.toCharArray());

            if (currentEntity == null) {
                currentEntity = PadlParserUtil.createGhost(aPadlModel, currentEntityID.toCharArray());
            }
        } else {
            currentEntity = PadlParserUtil.createGhost(aPadlModel, currentEntityID.toCharArray());
        }

        // create the member entities
        IFirstClassEntity currentMemberEntity;
        String currentMemberEntityID;
        String currentMemberEntityName;

        while (tokenizer.hasMoreTokens()) {
            currentMemberEntityName = tokenizer.nextToken();
            currentMemberEntityID = currentEntity.getDisplayID() + '$' + currentMemberEntityName;

            currentMemberEntity = (IFirstClassEntity) currentEntity
                    .getConstituentFromID(currentMemberEntityID.toCharArray());

            if (currentMemberEntity == null) {
                currentMemberEntity = aPadlModel.getFactory().createMemberGhost(
                        currentMemberEntityID.toCharArray(), currentMemberEntityName.toCharArray());
                currentEntity.addConstituent((IConstituentOfEntity) currentMemberEntity);
            }
            currentEntity = currentMemberEntity;
        }
        // The last entity created or got in the padl model is which
        // is searched for
        return currentEntity;
    }
}

From source file:com.sap.research.connectivity.gw.GWOperationsUtils.java

public void addLocalFieldInPersistenceMethods(JavaSourceFileEditor entityClassFile, String fieldName,
        String fieldType) {//from  w  w  w  .ja  va  2 s. c om
    ArrayList<JavaSourceMethod> globalMethodList = entityClassFile.getGlobalMethodList();
    String pluralRemoteEntity = GwUtils.getInflectorPlural(entityClassFile.CLASS_NAME, Locale.ENGLISH);
    String smallRemoteEntity = StringUtils.uncapitalize(entityClassFile.CLASS_NAME);

    for (JavaSourceMethod method : globalMethodList) {
        String methodName = method.getMethodName();

        /*
         * We insert the new field in the findAll and find<Entity>Entries methods
         */
        if (methodName.endsWith("findAll" + pluralRemoteEntity)
                || methodName.endsWith("find" + entityClassFile.CLASS_NAME + "Entries")) {
            StringBuffer methodBody = new StringBuffer(method.getMethodBody());
            methodBody.insert(methodBody.indexOf("virtual" + entityClassFile.CLASS_NAME + "List.add"),
                    makeLocalShowFieldCode("\t\t", smallRemoteEntity + "Instance", entityClassFile.CLASS_NAME,
                            fieldName));
            method.setMethodBody(methodBody.toString());
        }

        /* NO NEED TO INSERT IN THE FIND METHOD ANYMORE AS ONCE FOUND IN THE LOCAL DB, THE LOCAL FIELDS ARE AUTOMATICALLY POPULATED
         * We insert the new field in the find<Entity> method
         *
        else if (methodName.endsWith("find" + entityClassFile.CLASS_NAME)) {
           StringBuffer methodBody = new StringBuffer(method.getMethodBody());
           methodBody.insert(methodBody.indexOf("return "), 
          makeLocalShowFieldCode("\t", "virtual" + entityClassFile.CLASS_NAME, entityClassFile.CLASS_NAME, fieldName));
           method.setMethodBody(methodBody.toString());
        }*/
    }
}

From source file:org.ejbca.ui.web.protocol.OCSPServlet.java

/**
 * Reads the request bytes and verifies min and max size of the request. If an error occurs it throws a MalformedRequestException. 
 * Can get request bytes both from a HTTP GET and POST request
 * /*w w w . jav  a  2 s . c o m*/
 * @param request
 * @param response
 * @return the request bytes or null if an error occured.
 * @throws IOException In case there is no stream to read
 * @throws MalformedRequestException 
 */
private byte[] checkAndGetRequestBytes(HttpServletRequest request, HttpMethod httpMethod)
        throws IOException, MalformedRequestException {
    final byte[] ret;
    // Get the request data
    final int n = request.getContentLength();
    // Expect n might be -1 for HTTP GET requests
    if (log.isDebugEnabled()) {
        log.debug(">checkAndGetRequestBytes. Received " + httpMethod.name() + " request with content length: "
                + n + " from " + request.getRemoteAddr());
    }
    if (n > LimitLengthASN1Reader.MAX_REQUEST_SIZE) {
        String msg = intres.getLocalizedMessage("ocsp.toolarge", LimitLengthASN1Reader.MAX_REQUEST_SIZE, n);
        log.info(msg);
        throw new MalformedRequestException(msg);
    }
    // So we passed basic tests, now we can read the bytes, but still keep an eye on the size
    // we can not fully trust the sent content length.
    if (HttpMethod.POST.equals(httpMethod)) {
        final ServletInputStream in = request.getInputStream(); // ServletInputStream does not have to be closed, container handles this
        LimitLengthASN1Reader limitLengthASN1Reader = new LimitLengthASN1Reader(in, n);
        try {
            ret = limitLengthASN1Reader.readFirstASN1Object();
            if (n > ret.length) {
                // The client is sending more data than the OCSP request. It might be slightly broken or trying to bog down the server on purpose.
                // In the interest of not breaking existing systems that might have slightly broken clients we just log for a warning for now.
                String msg = intres.getLocalizedMessage("ocsp.additionaldata", ret.length, n);
                log.warn(msg);
            }
        } finally {
            limitLengthASN1Reader.close();
        }
    } else if (HttpMethod.GET.equals(httpMethod)) {
        // GET request
        final StringBuffer url = request.getRequestURL();
        // RFC2560 A.1.1 says that request longer than 255 bytes SHOULD be sent by POST, we support GET for longer requests anyway.
        if (url.length() <= LimitLengthASN1Reader.MAX_REQUEST_SIZE) {
            final String decodedRequest;
            try {
                // We have to extract the pathInfo manually, to avoid multiple slashes being converted to a single
                // According to RFC 2396 2.2 chars only have to encoded if they conflict with the purpose, so
                // we can for example expect both '/' and "%2F" in the request.
                final String fullServletpath = request.getContextPath() + request.getServletPath();
                final int paramIx = Math.max(url.indexOf(fullServletpath), 0) + fullServletpath.length() + 1;
                final String requestString = paramIx < url.length() ? url.substring(paramIx) : "";
                decodedRequest = URLDecoder.decode(requestString, "UTF-8").replaceAll(" ", "+");
            } catch (Exception e) {
                String msg = intres.getLocalizedMessage("ocsp.badurlenc");
                log.info(msg);
                throw new MalformedRequestException(e);
            }
            if (decodedRequest != null && decodedRequest.length() > 0) {
                if (log.isDebugEnabled()) {
                    // Don't log the request if it's too long, we don't want to cause denial of service by filling log files or buffers.
                    if (decodedRequest.length() < 2048) {
                        log.debug("decodedRequest: " + decodedRequest);
                    } else {
                        log.debug("decodedRequest too long to log: " + decodedRequest.length());
                    }
                }
                try {
                    ret = Base64.decode(decodedRequest.getBytes());
                } catch (Exception e) {
                    String msg = intres.getLocalizedMessage("ocsp.badurlenc");
                    log.info(msg);
                    throw new MalformedRequestException(e);
                }
            } else {
                String msg = intres.getLocalizedMessage("ocsp.missingreq");
                log.info(msg);
                throw new MalformedRequestException(msg);
            }
        } else {
            String msg = intres.getLocalizedMessage("ocsp.toolarge", LimitLengthASN1Reader.MAX_REQUEST_SIZE,
                    url.length());
            log.info(msg);
            throw new MalformedRequestException(msg);
        }
    } else {
        // Strange, an unknown method
        String msg = intres.getLocalizedMessage("ocsp.unknownmethod", request.getMethod());
        log.info(msg);
        throw new MalformedRequestException(msg);
    }
    // Make a final check that we actually received something
    if (ret == null || ret.length == 0) {
        String msg = intres.getLocalizedMessage("ocsp.emptyreq", request.getRemoteAddr());
        log.info(msg);
        throw new MalformedRequestException(msg);
    }
    return ret;
}

From source file:it.eng.spagobi.commons.utilities.urls.WebUrlBuilder.java

public String getUrl(HttpServletRequest aHttpServletRequest, Map parameters) {
    logger.debug("IN");
    init(aHttpServletRequest);/*from   www.  ja va 2  s.  c  om*/
    //ConfigSingleton.getInstance().getAttribute(dal master fin qua SPAGO_ADAPTERHTTP_URL)
    StringBuffer sb = new StringBuffer();
    sb.append(baseURL);
    if (parameters != null) {
        Iterator keysIt = parameters.keySet().iterator();
        boolean isFirst = true;
        String paramName = null;
        Object paramValue = null;
        while (keysIt.hasNext()) {
            paramName = (String) keysIt.next();
            paramValue = parameters.get(paramName);
            if (paramValue == null) {
                logger.warn("Parameter with name " + paramName
                        + " has null value. This parameter will be not considered.");
                continue;
            }
            if (isFirst) {
                sb.append("?");
                isFirst = false;
            } else {
                sb.append("&");
            }
            sb.append(paramName + "=" + paramValue.toString());
        }
    }
    // propagating light navigator id
    String lightNavigatorId = aHttpServletRequest.getParameter(LightNavigationManager.LIGHT_NAVIGATOR_ID);
    if (lightNavigatorId != null && !lightNavigatorId.trim().equals("")) {
        if (sb.indexOf("?") != -1) {
            sb.append("&" + LightNavigationManager.LIGHT_NAVIGATOR_ID + "=" + lightNavigatorId);
        } else {
            sb.append("?" + LightNavigationManager.LIGHT_NAVIGATOR_ID + "=" + lightNavigatorId);
        }
    }
    String url = sb.toString();

    logger.debug("OUT.url=" + url);
    return url;
}

From source file:org.xwiki.editor.tool.autocomplete.internal.AutoCompletionResource.java

/**
 * Parses the passed content and return the autocompletion hints for the passed cursor position.
 *
 * @param content the Velocity content to autocomplete
 * @param offset the position of the cursor relative to the Velocity content
 * @return the list of autocompletion hints
 *///from  ww  w.  j  a v a 2s .  c o  m
private Hints getHints(String content, int offset) {
    Hints results = new Hints();

    // General algorithm:
    // - We start parsing at the first dollar before the cursor
    // - We get the full reference (a reference in VTL can be a variable, a property or a method call, see
    // http://velocity.apache.org/engine/devel/user-guide.html#References)
    // - We split the reference on "." and handle first the case of a variable. If there's no "." then it means
    // we're autocompleting a variable and we find all matching Velocity context variables and return them.
    // - If there's at least one "." then we parse the whole chain of method calls till the last dot to find the
    // return type of the last method call. This allows us to know the full list of methods for autocompletion.

    // Find the dollar sign before the current position
    char[] chars = content.toCharArray();
    VelocityContext velocityContext = getVelocityContext();
    int dollarPos = StringUtils.lastIndexOf(content, '$', offset);

    if (dollarPos == -1) {
        return results;
    }

    // Special case for when there's no variable after the dollar position since the Velocity Parser doesn't
    // support parsing this case.
    if (isCursorDirectlyAfterDollar(chars, dollarPos, offset)) {
        // Find all objects bound to the Velocity Context. We need to also look in the chained context since
        // this is where we store Velocity Tools
        results = getVelocityContextKeys("", velocityContext);
    } else {
        // The cursor is not directly after the dollar sign.
        try {
            // Get all the references after the dollar sign. For example if the input is "$a.b().ccc" then
            // we get "a.b().ccc".
            VelocityParserContext context = new VelocityParserContext();
            StringBuffer reference = new StringBuffer();
            StringBuffer identifier = new StringBuffer();
            int endPos = this.parser.getVar(chars, dollarPos, identifier, reference, context);

            // If endPos matches the current cursor position then it means we have a valid token for
            // autocompletion. Otherwise we don't autocomplete (for example there could be spaces between the
            // reference and the cursor position).
            // Note: We need to handle the special when the cursor is just after the '.' char.
            if (endPos + 1 == offset && chars[endPos] == '.') {
                endPos++;
                reference.append('.');
            }
            if (endPos == offset) {
                // Find out if we're autocompleting a variable. In this case there's no "." in the reference
                int methodPos = reference.indexOf(".");
                if (methodPos > -1) {
                    // Autocomplete a method!
                    results = getHintsForMethodCall(chars, dollarPos + methodPos, identifier.toString());
                } else {
                    // Autocomplete a variable! Find all matching variables.
                    results = getVelocityContextKeys(identifier.toString(), velocityContext);
                }
            }
        } catch (InvalidVelocityException e) {
            this.logger.debug("Failed to get autocomplete hints for content [{}] at offset [{}]",
                    new Object[] { content, offset, e });
        }
    }

    return results;
}

From source file:com.eryansky.common.utils.SysUtils.java

/**
  * ??????.1lo0/*w w w .  j a v  a  2s  . c om*/
  * <p/>
  * ?1-9 a-z A-Z
  * 
  * @param length
  *            
  * @return ????
  */
 public static String getRandomString(int length) {
     StringBuffer bu = new StringBuffer();
     String[] arr = { "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
             "k", "m", "n", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F",
             "G", "H", "I", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
     Random random = new Random();
     while (bu.length() < length) {
         String temp = arr[random.nextInt(57)];
         if (bu.indexOf(temp) == -1) {
             bu.append(temp);
         }
     }
     return bu.toString();
 }

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

public void importQuestions(String context, Pool pool, String text) throws AssessmentPermissionException {
    if ((text == null) || (text.length() == 0))
        return;/*from ww w  . j  a  va 2s  .  c o m*/

    // replace any \r\n with just a \n
    text = text.replaceAll("\r\n", "\n");

    String title = "eCollege paste";
    Float points = new Float("1");

    if (pool == null) {
        pool = this.poolService.newPool(context);
        //read title from the first line ex: Unit 2: Week 2 - Quiz
        String findTitle = text.substring(0, text.indexOf("\n"));
        if (findTitle != null) {
            String[] titleParts = findTitle.split("[:-]");
            if (titleParts.length == 2 && titleParts[1] != null && titleParts[1].length() != 0)
                title = titleParts[1].trim();
            else if (titleParts.length > 2)
                title = findTitle.substring(findTitle.indexOf(titleParts[1]));
        }
        pool.setTitle(title);
        pool.setPointsEdit(points);

        // create assessment
        Assessment assmt = assessmentService.newAssessment(context);
        assmt.setType(AssessmentType.test);
        assmt.setTitle(title);

        Part part = assmt.getParts().addPart();

        Pattern p_groups = Pattern.compile("Collapse[\\s]*Question(.*?)[\\n]*[\\t]*row[\\t]*Move[\\s]*Question",
                Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.DOTALL);
        Matcher m = p_groups.matcher(text);

        StringBuffer sb = new StringBuffer();
        while (m.find()) {
            String workOn = m.group(0);
            String[] lines = workOn.split("[\\n]");
            processECollegeTextGroup(pool, part, lines);
            m.appendReplacement(sb, "");
        }
        m.appendTail(sb);

        // remaining last text
        if (sb != null && sb.length() != 0) {
            if (sb.indexOf("Collapse Question") != -1) {
                String workOn = sb.substring(sb.indexOf("Collapse Question"));
                String[] lines = workOn.split("[\\n]");
                processECollegeTextGroup(pool, part, lines);
            }
        }

        try {
            assmt.getGrading().setGradebookIntegration(Boolean.TRUE);

            if (assmt.getParts().getTotalPoints().floatValue() <= 0) {
                assmt.setNeedsPoints(Boolean.FALSE);
            }

            assessmentService.saveAssessment(assmt);
        } catch (AssessmentPolicyException ep) {

        }
        this.poolService.savePool(pool);

    }
}

From source file:marytts.tools.dbselection.WikipediaMarkupCleaner.java

private StringBuffer removeSectionRef(Scanner s, StringBuffer lineIn) {
    String next;//from  www .  j  a v a 2 s  . c om
    int index1 = 0, index2 = -1, index3 = -1, endTagLength = 0, numRef = 0;
    boolean closeRef = true;
    StringBuffer line = new StringBuffer(lineIn);
    StringBuffer nextLine;

    while ((index1 = line.indexOf("<ref")) >= 0) { // in one line can be more than one reference
        numRef++;
        if ((index2 = line.indexOf("</ref>", index1)) >= 0)
            endTagLength = 6 + index2;
        else if ((index3 = line.indexOf("/>", index1)) >= 0)
            endTagLength = 2 + index3;

        if (index2 == -1 && index3 == -1) {// the </ref> most be in the next lines, so get more lines until the </ref> is found
            while (s.hasNext() && numRef != 0) {
                nextLine = new StringBuffer(s.nextLine());
                if (nextLine.indexOf("<ref") >= 0)
                    numRef++;
                line.append(nextLine);
                if ((index2 = line.indexOf("</ref>", index1)) >= 0) {
                    numRef--;
                    endTagLength = 6 + index2;
                } else if ((index3 = line.indexOf("/>", index1)) >= 0) {
                    numRef--;
                    endTagLength = 2 + index3;
                }
            }

        } else // the endTag was found
            numRef--;

        if (numRef == 0) {
            index1 = line.indexOf("<ref"); // get again this because the position might change
            if (endTagLength > index1) {
                line.delete(index1, endTagLength);
                //System.out.println("nextline="+line);
            } else {
                if (debug) {
                    System.out.print("iniTag: <ref  index1=" + index1);
                    System.out.print("  endTagLength=" + endTagLength);
                    System.out.println("  line.length=" + line.length() + "  line: " + line);
                    System.out.println("removeSectionRef: WARNING endTagLength > length of line: " + line);
                    //line.delete(index1, line.length());
                }
                line = new StringBuffer("");
            }
        } else {
            if (debug)
                System.out.println("removeSectionRef: WARNING no </ref> or /> in " + line);
            //line.delete(index1, line.length());
            line = new StringBuffer("");
        }

    } // while this line contains iniTag-s

    return line;

}

From source file:org.ecoinformatics.datamanager.database.DelimitedReader.java

private String readOneRowDataString() {
    //Vector oneRowDataVector = new Vector();
    StringBuffer rowData = new StringBuffer();
    String rowDataString = null;//w  ww. j ava2  s. c  o m
    int singleCharactor; // = -2;

    if (dataReader != null) {
        //log.debug("in dataReader is not null");
        try {
            //read the first character to start things off  
            singleCharactor = dataReader.read();
            while (singleCharactor != -1) {
                //log.debug("singleCharactor is not EOF");
                char charactor = (char) singleCharactor;
                rowData.append(charactor);

                // find string - line ending in the row data   
                if (rowData.indexOf(lineEnding) != -1) {
                    //log.debug("found line ending");
                    // strip the header lines
                    if (stripHeader && numHeaderLines > 0 && headLineNumberCount < numHeaderLines) {
                        // reset string buffer(discard the header line)
                        rowData = null;
                        rowData = new StringBuffer();

                    } else {
                        rowDataString = rowData.toString();
                        //log.debug("The row data is " + rowDataString);
                        break;
                    }

                    headLineNumberCount++;
                }
                //read the next character before looping back
                singleCharactor = dataReader.read();
            }
        } catch (Exception e) {
            //log.debug("Couldn't read data from input stream");
            e.printStackTrace();
            rowData = new StringBuffer();
        }
    }

    //if we have data for the row, then return it
    if (rowData != null && rowData.length() > 0) {
        rowDataString = rowData.toString();
    }
    //System.out.println("the row data before return is "+rowDataString);
    return rowDataString;
}

From source file:org.eclim.plugin.jdt.command.src.ClassPrototypeCommand.java

/**
 * Top level method for generating a prototype of the supplied type.
 *
 * @param type The type.// w w  w.  j  a v a2s .  c  om
 * @return The resulting prototype.
 */
protected String prototype(IType type) throws Exception {
    Set<String> imports = new TreeSet<String>();
    StringBuffer buffer = new StringBuffer();
    buffer.append(Services.getMessage("prototype.header"));
    buffer.append("package ").append(type.getPackageFragment().getElementName()).append(";\n");
    prototype(buffer, type, "", imports);

    // insert the imports
    StringBuffer importClauses = new StringBuffer().append("\n\n");
    for (String className : imports) {
        importClauses.append("import ").append(className).append(";\n");
    }

    buffer.insert(buffer.indexOf(";") + 1, importClauses.toString());

    return buffer.toString();
}