Java Code Examples for org.apache.commons.lang.StringUtils.indexOf()

The following are Jave code examples for showing how to use indexOf() of the org.apache.commons.lang.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: patcher   File: ClassesExportAction.java   View Source Code Vote up 7 votes
private void getVirtualFile(String sourceName, VirtualFile virtualFile[], String compileRoot)
        throws Exception {
    if (!ArrayUtils.isEmpty(virtualFile)) {
        VirtualFile arr$[] = virtualFile;
        int len$ = arr$.length;
        for (int i$ = 0; i$ < len$; i$++) {
            VirtualFile vf = arr$[i$];
            String srcName;
            if (StringUtils.indexOf(vf.toString(), "$") != -1)
                srcName = StringUtils.substring(vf.toString(), StringUtils.lastIndexOf(vf.toString(), "/") + 1, StringUtils.indexOf(vf.toString(), "$"));
            else
                srcName = StringUtils.substring(vf.toString(), StringUtils.lastIndexOf(vf.toString(), "/") + 1, StringUtils.length(vf.toString()) - 6);
            String dstName = StringUtils.substring(sourceName, 0, StringUtils.length(sourceName) - 5);
            if (StringUtils.equals(srcName, dstName)) {
                String outRoot = (new StringBuilder()).append(StringUtils.substring(compileRoot, 0, StringUtils.lastIndexOf(compileRoot, "/"))).append("/out").toString();
                String packagePath = StringUtils.substring(vf.getPath(), StringUtils.length(compileRoot), StringUtils.length(vf.getPath()));
                File s = new File(vf.getPath());
                File t = new File((new StringBuilder()).append(outRoot).append(packagePath).toString());
                FileUtil.copy(s, t);
            }
            if (!ArrayUtils.isEmpty(virtualFile))
                getVirtualFile(sourceName, vf.getChildren(), compileRoot);
        }

    }
}
 
Example 2
Project: wrdocletbase   File: AbstractDocBuilder.java   View Source Code Vote up 6 votes
protected String getBriefFromCommentText(String commentText) {
	int index = StringUtils.indexOf(commentText, '\n');
	if (index != -1) {
		commentText = StringUtils.substring(commentText, 0, index);
	}
	index = StringUtils.indexOfAny(commentText, ".!?。!?…");
	if (index > 0) {
		commentText = StringUtils.substring(commentText, 0, index);
	}
	if (StringUtils.length(commentText) > 8) {
		commentText = StringUtils.substring(commentText, 0, 8) + "…";
	}
	return commentText;
}
 
Example 3
Project: Hydrograph   File: StyledTextEventListener.java   View Source Code Vote up 6 votes
/**
 * The function will move the cursor in forward direction.
 * @param styledText
 * @param text
 * @param prevLineIndex
 * @param nextLineIndex
 * @return int[]
 */
public int[] nextButtonListener(StyledText styledText, String text, int prevLineIndex, int nextLineIndex){
	logger.debug("StyledText next button selected");
	int txtIndex = StringUtils.indexOf(StringUtils.lowerCase(styledText.getText()), StringUtils.lowerCase(text), nextLineIndex);
	
	if(txtIndex < 0){
		nextLineIndex = 0;
		prevLineIndex =  StringUtils.indexOf(StringUtils.lowerCase(styledText.getText()), StringUtils.lowerCase(text), nextLineIndex);
		nextLineIndex = prevLineIndex + 1;
		styledText.setSelection(prevLineIndex);
		setStyledRange(styledText, prevLineIndex, text.length(), null, Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
		return new int[]{prevLineIndex,nextLineIndex};
	}else{
		setStyledRange(styledText, txtIndex, text.length(), null, Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
		styledText.setSelection(txtIndex);
		prevLineIndex = txtIndex;
		nextLineIndex = txtIndex+1;
		styledText.redraw();
	}
	return new int[]{prevLineIndex,nextLineIndex};
}
 
Example 4
Project: Hydrograph   File: StyledTextEventListener.java   View Source Code Vote up 6 votes
/**
 * The function will change selected text background color.
 * @param styledText
 * @param text
 * @param foreground
 * @param background
 */
public void allButtonListener(StyledText styledText, String text, Color foreground, Color background, Label label){
	logger.debug("StyledText All button selected");
	int index = 0;
	int recordCount = 0;
	if(styledText == null){return;}
	for(;index < styledText.getText().length();){
		  int lastIndex = StringUtils.indexOf(StringUtils.lowerCase(styledText.getText()), StringUtils.lowerCase(text), index);
		  
		  if(lastIndex < 0){return;}
		  else{
			  setStyledRange(styledText, lastIndex, text.length(), null, background);
			  index = lastIndex + 1;
			  recordCount++ ;
			  label.setVisible(true);
			  label.setText("Matching count - " + recordCount);
		  }
	  }
}
 
Example 5
Project: lams   File: DateUtils.java   View Source Code Vote up 5 votes
/**
 * Index of sign charaters (i.e. '+' or '-').
 * 
 * @param str The string to search
 * @param startPos The start position
 * @return the index of the first sign character or -1 if not found
 */
private static int indexOfSignChars(String str, int startPos) {
    int idx = StringUtils.indexOf(str, '+', startPos);
    if (idx < 0) {
        idx = StringUtils.indexOf(str, '-', startPos);
    }
    return idx;
}
 
Example 6
Project: soundwave   File: EsBulkResponseSummary.java   View Source Code Vote up 5 votes
public String getFailedMessage(int max) {
  int count = 0;
  StringBuilder stringBuilder = new StringBuilder();
  for (Map.Entry<String, String> entry : failed.entrySet()) {
    if (StringUtils.indexOf(entry.getValue(), "VersionConflictEngineException") < 0) {
      stringBuilder.append(String.format("id:%s error:%s", entry.getKey(), entry.getValue()));
      count++;
      if (count >= max) {
        break;
      }
    }
  }
  return stringBuilder.toString();
}
 
Example 7
Project: Hydrograph   File: FindViewDataDialog.java   View Source Code Vote up 5 votes
private boolean isTextExist(StyledText styledText, String text){
	if(StringUtils.isNotBlank(styledText.getText())){
		int textIndex = StringUtils.indexOf(StringUtils.lowerCase(styledText.getText()), StringUtils.lowerCase(text), 0);
		if(textIndex < 0){
			label.setVisible(true);
			label.setText(labelText);
			return true;
		}else{
			label.setVisible(false);
			return false;
		}
	}else{ return false;}
	
}
 
Example 8
Project: dble   File: SendMakeHandler.java   View Source Code Vote up 5 votes
@Override
public void fieldEofResponse(byte[] headerNull, List<byte[]> fieldsNull, List<FieldPacket> fieldPackets,
                             byte[] eofNull, boolean isLeft, BackendConnection conn) {
    lock.lock();
    try {
        if (terminate.get())
            return;
        this.fieldPackets = fieldPackets;
        this.sourceFields = HandlerTool.createFields(this.fieldPackets);
        for (Item sel : selects) {
            Item tmpItem = HandlerTool.createItem(sel, this.sourceFields, 0, isAllPushDown(), type());
            tmpItem.setItemName(sel.getItemName());
            String selAlias = sel.getAlias();
            if (selAlias != null || tableAlias != null) {
                // remove the added tmp FNAF
                if (StringUtils.indexOf(selAlias, Item.FNAF) == 0)
                    selAlias = StringUtils.substring(selAlias, Item.FNAF.length());
            }
            tmpItem = HandlerTool.createRefItem(tmpItem, schema, table, tableAlias, selAlias);
            this.selItems.add(tmpItem);
        }
        List<FieldPacket> newFieldPackets = new ArrayList<>();
        for (Item selItem : this.selItems) {
            FieldPacket tmpFp = new FieldPacket();
            selItem.makeField(tmpFp);
            /* Keep things compatible for old clients */
            if (tmpFp.getType() == FieldTypes.MYSQL_TYPE_VARCHAR.numberValue())
                tmpFp.setType(FieldTypes.MYSQL_TYPE_VAR_STRING.numberValue());
            newFieldPackets.add(tmpFp);
        }
        nextHandler.fieldEofResponse(null, null, newFieldPackets, null, this.isLeft, conn);
    } finally {
        lock.unlock();
    }
}
 
Example 9
Project: Hydrograph   File: ExternalSchemaUtil.java   View Source Code Vote up 4 votes
/**
 * Converts UI grid-row object to its equivalent Jaxb Object
 * 
 * @param gridRow
 * @return
 */
public Field convertGridRowToJaxbSchemaField(GridRow gridRow) {
	Field field = new Field();
	if (StringUtils.indexOf(gridRow.getFieldName(), "}") - StringUtils.indexOf(gridRow.getFieldName(), "@{") >= 3) {
		Utils.INSTANCE.loadProperties();
		String paramValue = Utils.INSTANCE.getParamValueForRunSql(gridRow.getFieldName());
		field.setName(paramValue);
	} else {
		field.setName(gridRow.getFieldName());
	}
	field.setType(FieldDataTypes.fromValue(gridRow.getDataTypeValue()));
	
	if(gridRow instanceof XPathGridRow){
		if(StringUtils.isNotBlank(((XPathGridRow)gridRow).getXPath())){
			field.setAbsoluteOrRelativeXpath((((XPathGridRow)gridRow).getXPath()));
		}
	}
	
	if(StringUtils.isNotBlank(gridRow.getDateFormat())){
		field.setFormat(gridRow.getDateFormat());
	}
	if(StringUtils.isNotBlank(gridRow.getPrecision())){
		field.setPrecision(Integer.parseInt(gridRow.getPrecision()));
	}
	if(StringUtils.isNotBlank(gridRow.getScale())){
		field.setScale(Integer.parseInt(gridRow.getScale()));
	}
	if(gridRow.getScaleTypeValue()!=null){
		if(!gridRow.getScaleTypeValue().equals("") && !gridRow.getScaleTypeValue().equals(Messages.SCALE_TYPE_NONE)){
			field.setScaleType(ScaleTypes.fromValue(gridRow.getScaleTypeValue()));
		}
	}
	if(StringUtils.isNotBlank(gridRow.getDescription())){
		field.setDescription(gridRow.getDescription());
	}

	if(gridRow instanceof FixedWidthGridRow){
		if(StringUtils.isNotBlank(((FixedWidthGridRow)gridRow).getLength())){
			field.setLength(new BigInteger(((FixedWidthGridRow)gridRow).getLength()));
		}
	}
	
	if(gridRow instanceof MixedSchemeGridRow){
		if(StringUtils.isNotBlank(((MixedSchemeGridRow)gridRow).getLength())){
			field.setLength(new BigInteger(((MixedSchemeGridRow)gridRow).getLength()));
		}
		
		if(StringUtils.isNotBlank(((MixedSchemeGridRow)gridRow).getDelimiter())){
			field.setDelimiter((((MixedSchemeGridRow)gridRow).getDelimiter()));
		}

	}

	if(gridRow instanceof GenerateRecordSchemaGridRow){
		if(StringUtils.isNotBlank(((GenerateRecordSchemaGridRow)gridRow).getLength())){
			field.setLength(new BigInteger(((GenerateRecordSchemaGridRow)gridRow).getLength()));
		}
		if(StringUtils.isNotBlank(((GenerateRecordSchemaGridRow) gridRow).getRangeFrom())){
			field.setRangeFrom((((GenerateRecordSchemaGridRow) gridRow).getRangeFrom()));
		}
		if(StringUtils.isNotBlank(((GenerateRecordSchemaGridRow) gridRow).getRangeTo())){
			field.setRangeTo(((GenerateRecordSchemaGridRow) gridRow).getRangeTo());
		}
		if(StringUtils.isNotBlank(((GenerateRecordSchemaGridRow) gridRow).getDefaultValue())){
			field.setDefault(((GenerateRecordSchemaGridRow) gridRow).getDefaultValue());
		}
	}
	return field;
}