Java 类org.apache.velocity.util.StringUtils 实例源码

项目:deltaforce    文件:VariableFieldModelBuilder.java   
/**
 * Applies common fields
 *
 * @param fieldModel mutable FieldModel
 * @return fieldModel
 */
public <A extends VariableFieldModel> A applyCommon(final A fieldModel) {
    fieldModel.accessible = !element.getModifiers().contains(Modifier.PRIVATE);

    fieldModel.name = element.getSimpleName().toString();
    fieldModel.accessorMethod = GET + StringUtils.capitalizeFirstLetter(fieldModel.name);
    fieldModel.alias = DFUtil.compileAlias(fieldModel.name, "");
    fieldModel.type = element.asType().toString();

    box(fieldModel, element.asType());

    onAnnotation(DeltaField.class, a -> fieldModel.alias = DFUtil.compileAlias(fieldModel.name, a.alias()) );

    printMessage(Kind.NOTE, "created field model:" + fieldModel.toString());

    return fieldModel;
}
项目:jpublish    文件:TagCloudComponent.java   
private Article newArticle(String articleId, JPublishContext context) {
    Article article = null;

    if (articleId != null) {
        Map articleProperties = (Map) context.get(articleId);
        List tags = (List) articleProperties.get(TAGS);
        article = new Article(articleId);

        for (int i = 0; i < tags.size(); i++) {
            String sTag = (String) tags.get(i);
            String[] props = StringUtils.split(sTag, tagSeparator);

            //Tag tag =
            article.addTag(props[0], Long.parseLong(props[1]));
            // tag.setProperty("score", props[2]);
            // todo think about implementing an API used to store arbitrary TAG attributes as defined by the user
        }
        article.calculateTags(normalizer);
    }
    return article;
}
项目:DWSurvey    文件:ObjectMapper.java   
/**
 * 定义Apache BeanUtils日期Converter的格式,可注册多个格式,以','分隔
 */
public static void registerDateConverter(String patterns) {
    DateConverter dc = new DateConverter();
    dc.setUseLocaleFormat(true);
    dc.setPatterns(StringUtils.split(patterns, ","));
    ConvertUtils.register(dc, Date.class);
}
项目:deltaforce    文件:DFUtil.java   
/**
 * @param name
 * @param aliasParam
 * @return
 */
public static String compileAlias(String name, String aliasParam) {
    /**
     *         #if( ${field.mapItem.substring(0,1)}=="+" )
     #set( $fnInMethod = "${field.alias.substring(0,1).toUpperCase()}${field.alias.substring(1)}${field.mapItem.substring(1)}" )
     #else
     #set ($fnInMethod = "${field.mapItem.substring(0,1).toUpperCase()}${field.mapItem.substring(1)}" )
     #end

     */
    String res = StringUtils.capitalizeFirstLetter(name);

    String[] aliasParts = StringUtils.split(aliasParam==null?"":aliasParam, ";");

    for(String alias:aliasParts) {
        if(alias.startsWith("+")) {
            res = res + StringUtils.capitalizeFirstLetter(alias.substring(1));
        }else if(alias.startsWith("-")) {
            if(res.endsWith(alias.substring(1))) {
                res = res.substring(0,res.length()-alias.length()+1);
            }
        }else {
            res = StringUtils.capitalizeFirstLetter(alias);
        }

    }
    return res;
}
项目:engerek    文件:PolicyRuleBasedAspect.java   
private PcpChildWfTaskCreationInstruction<ItemApprovalSpecificContent> prepareAssignmentRelatedTaskInstruction(
    ApprovalSchemaBuilder.Result builderResult,
    EvaluatedAssignment<?> evaluatedAssignment, boolean assignmentRemoved, ModelContext<?> modelContext,
    PrismObject<UserType> requester, OperationResult result) throws SchemaException {

String objectOid = getFocusObjectOid(modelContext);
String objectName = getFocusObjectName(modelContext);

@SuppressWarnings("unchecked")
PrismObject<? extends ObjectType> target = (PrismObject<? extends ObjectType>) evaluatedAssignment.getTarget();
Validate.notNull(target, "assignment target is null");

String targetName = target.getName() != null ? target.getName().getOrig() : "(unnamed)";
String operation = (assignmentRemoved
        ? "unassigning " + targetName + " from " :
        "assigning " + targetName + " to ")
        + objectName;
String approvalTaskName = "Approve " + operation;

PcpChildWfTaskCreationInstruction<ItemApprovalSpecificContent> instruction =
        PcpChildWfTaskCreationInstruction.createItemApprovalInstruction(getChangeProcessor(), approvalTaskName,
                builderResult.schemaType, builderResult.attachedRules);

instruction.prepareCommonAttributes(this, modelContext, requester);

ObjectDelta<? extends FocusType> delta = assignmentToDelta(modelContext.getFocusClass(),
        evaluatedAssignment.getAssignmentType(), assignmentRemoved, objectOid);
instruction.setDeltasToProcess(delta);

instruction.setObjectRef(modelContext, result);
instruction.setTargetRef(createObjectRef(target), result);

String andExecuting = instruction.isExecuteApprovedChangeImmediately() ? "and execution " : "";
instruction.setTaskName("Approval " + andExecuting + "of " + operation);
instruction.setProcessInstanceName(StringUtils.capitalizeFirstLetter(operation));

itemApprovalProcessInterface.prepareStartInstruction(instruction);

return instruction;
  }
项目:osmo    文件:OfflineScripter.java   
/**
 * Create the actual script from the RF scripter.
 *
 * @return The complete test script.
 */
public String createScript() {
  for (User user : state.getUsers()) {
    scripter.addVariable(user.getId(), StringUtils.capitalizeFirstLetter(user.getName()));
  }
  script = scripter.createScript();
  return script;
}
项目:android-codegenerator-plugin-intellij    文件:ProjectHelper.java   
public List<String> getSourceRootPathList(Project project, AnActionEvent event) {
    List<String> sourceRoots = Lists.newArrayList();
    String projectPath = StringUtils.normalizePath(project.getBasePath());
    for (VirtualFile virtualFile : getModuleRootManager(event).getSourceRoots(false)) {
        sourceRoots.add(StringUtils.normalizePath(virtualFile.getPath()).replace(projectPath, ""));
    }
    return sourceRoots;
}
项目:deltaforce    文件:DFUtil.java   
public StringUtils getStringUtils() {
    return STRING_UTILS;
}
项目:engerek    文件:PolicyRuleBasedAspect.java   
private PcpChildWfTaskCreationInstruction prepareObjectRelatedTaskInstruction(ApprovalSchemaBuilder.Result builderResult,
        ObjectDelta<?> focusDelta, Set<ItemPath> paths, ModelContext<?> modelContext,
        PrismObject<UserType> requester, OperationResult result) throws SchemaException {

    //String objectOid = getFocusObjectOid(modelContext);
    String objectName = getFocusObjectName(modelContext);

    String opName;
    if (focusDelta.isAdd()) {
        opName = "addition";
    } else if (focusDelta.isDelete()) {
        opName = "deletion";
    } else {
        opName = "modification";
    }

    if (focusDelta.isAdd()) {
        if (focusDelta.getObjectToAdd().getOid() == null) {
            String newOid = OidUtil.generateOid();
            focusDelta.getObjectToAdd().setOid(newOid);
            ((LensFocusContext<?>) modelContext.getFocusContext()).setOid(newOid);
        }
    }

    String approvalTaskName = "Approve " + opName + " of " + objectName;

    PcpChildWfTaskCreationInstruction<ItemApprovalSpecificContent> instruction =
            PcpChildWfTaskCreationInstruction.createItemApprovalInstruction(getChangeProcessor(), approvalTaskName,
                    builderResult.schemaType, builderResult.attachedRules);

    instruction.prepareCommonAttributes(this, modelContext, requester);

    @SuppressWarnings("unchecked")
    ObjectDelta<? extends FocusType> delta = (ObjectDelta<? extends FocusType>) subtractModifications(focusDelta, paths);
    instruction.setDeltasToProcess(delta);

    instruction.setObjectRef(modelContext, result);

    String andExecuting = instruction.isExecuteApprovedChangeImmediately() ? "and execution " : "";
    instruction.setTaskName("Approval " + andExecuting + "of " + opName + " of " + objectName);
    instruction.setProcessInstanceName(StringUtils.capitalizeFirstLetter(opName) + " of " + objectName);

    itemApprovalProcessInterface.prepareStartInstruction(instruction);

    return instruction;
}
项目:intellij-ce-playground    文件:FileTemplateUtil.java   
private static VelocityContext createVelocityContext() {
  VelocityContext context = new VelocityContext();
  context.put("StringUtils", StringUtils.class);
  return context;
}
项目:android-codegenerator-plugin-intellij    文件:PathHelper.java   
public String getFolderPath(String sourcePath, String packageName) {
    String normalizePath = StringUtils.normalizePath(sourcePath + "/" + StringUtils.getPackageAsPath(packageName));
    return org.apache.commons.lang3.StringUtils.strip(normalizePath, "/");
}
项目:tools-idea    文件:FileTemplateUtil.java   
private static VelocityContext createVelocityContext() {
  VelocityContext context = new VelocityContext();
  context.put("StringUtils", StringUtils.class);
  return context;
}
项目:spacewalk    文件:PowerManagementConfigurationAction.java   
/**
 * Runs this action.
 * @param mapping action mapping
 * @param formIn form submitted values
 * @param request http request object
 * @param response http response object
 * @return an action forward object
 */
@Override
public ActionForward execute(ActionMapping mapping, ActionForm formIn,
    HttpServletRequest request, HttpServletResponse response) {
    RequestContext context = new RequestContext(request);
    DynaActionForm form = (DynaActionForm) formIn;
    StrutsDelegate strutsDelegate = getStrutsDelegate();
    User user = context.getCurrentUser();
    ActionErrors errors = new ActionErrors();
    int successCount = 0;

    if (context.isSubmitted() && context.wasDispatched(
            "ssm.provisioning.powermanagement.configuration.update")) {
        List<SystemOverview> systemOverviews = getResult(context);
        for (SystemOverview systemOverview : systemOverviews) {
            try {
                Server server = SystemManager.lookupByIdAndUser(systemOverview.getId(),
                    user);
                CobblerPowerSettingsUpdateCommand command = PowerManagementAction
                    .getPowerSettingsUpdateCommandSSM(form, user, server);
                if (command.store() == null) {
                    successCount += 1;
                }
            }
            catch (XmlRpcException e) {
                log.error(StringUtils.stackTrace(e));
                log.error(StringUtils.stackTrace(e.getCause()));
            }
        }

        createSuccessMessage(request,
            "ssm.provisioning.powermanagement.configuration.saved", "" + successCount);
    }

    Map<String, String> types = PowerManagementAction.setUpPowerTypes(request,
            strutsDelegate, errors);
    PowerManagementAction.ensureAgentInstalled(request, strutsDelegate, errors);
    if (!types.isEmpty()) {
        types.put(
            LocalizationService.getInstance().getPlainText(
                "ssm.provisioning.powermanagement.configuration.dontchange"), "");
    }

    ListHelper helper = new ListHelper(this, request);
    helper.execute();

    return strutsDelegate.forwardParams(mapping.findForward(RhnHelper.DEFAULT_FORWARD),
        request.getParameterMap());
}
项目:urlaubsverwaltung    文件:TestDataCreator.java   
public static Person createPerson(String username, Role... roles) {

        String name = StringUtils.capitalizeFirstLetter(username);

        Person person = TestDataCreator.createPerson(username, name, name, username + "@test.de");

        person.setPermissions(Arrays.asList(roles));

        return person;
    }
项目:urlaubsverwaltung    文件:TestDataCreator.java   
public static Person createPerson(String username) {

        String name = StringUtils.capitalizeFirstLetter(username);

        return TestDataCreator.createPerson(username, name, name, username + "@test.de");
    }