Example usage for java.lang Character valueOf

List of usage examples for java.lang Character valueOf

Introduction

In this page you can find the example usage for java.lang Character valueOf.

Prototype

@HotSpotIntrinsicCandidate
public static Character valueOf(char c) 

Source Link

Document

Returns a Character instance representing the specified char value.

Usage

From source file:org.apache.ranger.plugin.util.RangerResourceTrie.java

public RangerResourceTrie(RangerServiceDef.RangerResourceDef resourceDef, List<T> evaluators) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> RangerResourceTrie(" + resourceDef.getName() + ", evaluatorCount=" + evaluators.size()
                + ")");
    }/*w w w .  j  ava  2 s.com*/

    Map<String, String> matcherOptions = resourceDef.getMatcherOptions();

    boolean optReplaceTokens = RangerAbstractResourceMatcher.getOptionReplaceTokens(matcherOptions);

    String tokenReplaceSpecialChars = "";

    if (optReplaceTokens) {
        char delimiterStart = RangerAbstractResourceMatcher.getOptionDelimiterStart(matcherOptions);
        char delimiterEnd = RangerAbstractResourceMatcher.getOptionDelimiterEnd(matcherOptions);
        char delimiterEscape = RangerAbstractResourceMatcher.getOptionDelimiterEscape(matcherOptions);

        tokenReplaceSpecialChars += delimiterStart;
        tokenReplaceSpecialChars += delimiterEnd;
        tokenReplaceSpecialChars += delimiterEscape;
    }

    this.resourceName = resourceDef.getName();
    this.optIgnoreCase = RangerAbstractResourceMatcher.getOptionIgnoreCase(matcherOptions);
    this.optWildcard = RangerAbstractResourceMatcher.getOptionWildCard(matcherOptions);
    this.wildcardChars = optWildcard ? DEFAULT_WILDCARD_CHARS + tokenReplaceSpecialChars
            : "" + tokenReplaceSpecialChars;
    this.root = new TrieNode(Character.valueOf((char) 0));

    for (T evaluator : evaluators) {
        Map<String, RangerPolicyResource> policyResources = evaluator.getPolicyResource();
        RangerPolicyResource policyResource = policyResources != null ? policyResources.get(resourceName)
                : null;

        if (policyResource == null) {
            if (evaluator.getLeafResourceLevel() != null && resourceDef.getLevel() != null
                    && evaluator.getLeafResourceLevel() < resourceDef.getLevel()) {
                root.addWildcardEvaluator(evaluator);
            }

            continue;
        }

        if (policyResource.getIsExcludes()) {
            root.addWildcardEvaluator(evaluator);
        } else {
            RangerResourceMatcher resourceMatcher = evaluator.getResourceMatcher(resourceName);

            if (resourceMatcher != null && (resourceMatcher.isMatchAny())) {
                root.addWildcardEvaluator(evaluator);
            } else {
                if (CollectionUtils.isNotEmpty(policyResource.getValues())) {
                    for (String resource : policyResource.getValues()) {
                        insert(resource, policyResource.getIsRecursive(), evaluator);
                    }
                }
            }
        }
    }

    root.postSetup(null);

    LOG.info(toString());

    if (LOG.isDebugEnabled()) {
        LOG.debug("<== RangerResourceTrie(" + resourceDef.getName() + ", evaluatorCount=" + evaluators.size()
                + "): " + toString());
    }
}

From source file:org.apache.camel.dataformat.csv.CsvDataFormatTest.java

@Test
public void shouldDisableCommentMarker() {
    CsvDataFormat dataFormat = new CsvDataFormat().setCommentMarkerDisabled(true).setCommentMarker('c');

    // Properly saved
    assertSame(CSVFormat.DEFAULT, dataFormat.getFormat());
    assertTrue(dataFormat.isCommentMarkerDisabled());
    assertEquals(Character.valueOf('c'), dataFormat.getCommentMarker());

    // Properly used
    assertNull(dataFormat.getActiveFormat().getCommentMarker());
}

From source file:org.wso2.carbon.identity.provider.openid.OpenIDUtil.java

/**
 * @param text//from   w w w . j a va 2  s  .c o m
 * @return
 */
private static String normalizeUrlEncoding(String text) {

    if (text == null) {
        return null;
    }

    int len = text.length();
    StringBuilder normalized = new StringBuilder(len);

    for (int i = 0; i < len; i++) {
        char current = text.charAt(i);
        if (current == '%' && i < len - 2) {
            String percentCode = text.substring(i, i + 3).toUpperCase();
            try {
                String str = URLDecoder.decode(percentCode, "ISO-8859-1");
                char chr = str.charAt(0);
                if (UNRESERVED_CHARACTERS.contains(Character.valueOf(chr))) {
                    normalized.append(chr);
                } else {
                    normalized.append(percentCode);
                }
            } catch (UnsupportedEncodingException e) {
                normalized.append(percentCode);
            }
            i += 2;
        } else {
            normalized.append(current);
        }
    }
    return normalized.toString();
}

From source file:com.act.lcms.db.model.PlateWell.java

public String getCoordinatesString() {
    if (plateRow == null || plateColumn == null) {
        return "(unknown)";
    }//from w w w .ja  v  a  2 s  . co m
    return String.format("%s%d", Character.valueOf((char) (this.getPlateRow() + 'A')).toString(),
            this.getPlateColumn() + 1);
}

From source file:termint.gui.vt.VTElement.java

public static VTElement fromString(String s) {
    Matcher match = fromStringPattern.matcher(s);
    assert match.matches() : "Failed match.  Regex=" + fromStringPattern.pattern() + ".  String=" + s;
    int captures = match.groupCount();
    assert captures == 8 : "VTElements have 8 captures.  Got " + captures;
    return new VTElement(Character.valueOf(match.group(1).charAt(0)), VT100Color.valueOf(match.group(2)),
            VT100Color.valueOf(match.group(3)), match.group(4).length() > 0, match.group(5).length() > 0,
            match.group(6).length() > 0, match.group(7).length() > 0, match.group(8).length() > 0);
}

From source file:org.apache.axis2.corba.idl.values.UnionValue.java

private void populateDiscriminator() {
    Member[] members = getMembers();
    UnionMember unionMember = null;
    for (int i = 0; i < members.length; i++) {
        unionMember = (UnionMember) members[i];
        if (unionMember.getName().equals(memberName))
            break;
    }/*w ww .j  av a  2  s .c  o m*/
    if (unionMember != null) {
        setMemberType(unionMember.getDataType());
        if (!unionMember.isDefault()) {
            discriminator = CorbaUtil.parseValue(((UnionType) dataType).getDiscriminatorType(),
                    unionMember.getDiscriminatorValue());
        } else if (unionMember.isDefault()) {
            DataType discriminatorType = ((UnionType) dataType).getDiscriminatorType();
            int kindVal = discriminatorType.getTypeCode().kind().value();
            switch (kindVal) {
            case TCKind._tk_long:
                discriminator = Integer.valueOf(-2147483648);
                break;
            case TCKind._tk_char:
            case TCKind._tk_wchar:
                discriminator = Character.valueOf('\u0000');
                break;
            case TCKind._tk_enum:
                EnumType enumType = (EnumType) discriminatorType;
                EnumValue enumValue = new EnumValue(enumType);
                enumValue.setValue(0);
                discriminator = enumValue;
                break;
            default:
                log.error("Unsupported union member type");
            }
        } else {
            discriminator = null;
        }
    }
}

From source file:com.thinkbiganalytics.discovery.parsers.csv.CSVAutoDetect.java

private Character guessQuote(List<LineStats> lineStats) {
    Character[] quoteTypeSupported = { Character.valueOf('"'), Character.valueOf('\'') };
    boolean match = false;
    for (Character quoteType : quoteTypeSupported) {
        boolean quoteTypeFound = lineStats.stream()
                .anyMatch(lineStat -> lineStat.containsNoDelimCharOfType(quoteType));
        if (quoteTypeFound) {
            match = lineStats.stream().allMatch(lineStat -> lineStat.hasLegalQuotedStringOfChar(quoteType));
        }/*from  w ww .j  av  a2  s.  com*/
        if (match) {
            return quoteType;
        }
    }
    return CSVFormat.DEFAULT.getQuoteCharacter();
}

From source file:org.apache.camel.dataformat.csv.CsvDataFormatTest.java

@Test
public void shouldOverrideCommentMarker() {
    CsvDataFormat dataFormat = new CsvDataFormat().setCommentMarker('c');

    // Properly saved
    assertSame(CSVFormat.DEFAULT, dataFormat.getFormat());
    assertEquals(Character.valueOf('c'), dataFormat.getCommentMarker());

    // Properly used
    assertEquals(Character.valueOf('c'), dataFormat.getActiveFormat().getCommentMarker());
}

From source file:com.glaf.core.util.Tools.java

public static Object getValue(Class<?> type, String propertyValue) {
    if (type == null || propertyValue == null || propertyValue.trim().length() == 0) {
        return null;
    }//  w ww . j  ava  2  s  . c  o m
    Object value = null;
    try {
        if (type == String.class) {
            value = propertyValue;
        } else if ((type == Integer.class) || (type == int.class)) {
            if (propertyValue.indexOf(',') != -1) {
                propertyValue = propertyValue.replaceAll(",", "");
            }
            value = Integer.parseInt(propertyValue);
        } else if ((type == Long.class) || (type == long.class)) {
            if (propertyValue.indexOf(',') != -1) {
                propertyValue = propertyValue.replaceAll(",", "");
            }
            value = Long.parseLong(propertyValue);
        } else if ((type == Float.class) || (type == float.class)) {
            if (propertyValue.indexOf(',') != -1) {
                propertyValue = propertyValue.replaceAll(",", "");
            }
            value = Float.valueOf(propertyValue);
        } else if ((type == Double.class) || (type == double.class)) {
            if (propertyValue.indexOf(',') != -1) {
                propertyValue = propertyValue.replaceAll(",", "");
            }
            value = Double.parseDouble(propertyValue);
        } else if ((type == Boolean.class) || (type == boolean.class)) {
            value = Boolean.valueOf(propertyValue);
        } else if ((type == Character.class) || (type == char.class)) {
            value = Character.valueOf(propertyValue.charAt(0));
        } else if ((type == Short.class) || (type == short.class)) {
            if (propertyValue.indexOf(',') != -1) {
                propertyValue = propertyValue.replaceAll(",", "");
            }
            value = Short.valueOf(propertyValue);
        } else if ((type == Byte.class) || (type == byte.class)) {
            value = Byte.valueOf(propertyValue);
        } else if (type == java.util.Date.class) {
            value = DateUtils.toDate(propertyValue);
        } else if (type == java.sql.Date.class) {
            value = DateUtils.toDate(propertyValue);
        } else if (type == java.sql.Timestamp.class) {
            value = DateUtils.toDate(propertyValue);
        } else if (type.isAssignableFrom(List.class)) {
        } else if (type.isAssignableFrom(Set.class)) {
        } else if (type.isAssignableFrom(Collection.class)) {
        } else if (type.isAssignableFrom(Map.class)) {
        } else {
            value = propertyValue;
        }
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
    return value;
}

From source file:org.apache.directory.fortress.web.panel.GroupListPanel.java

public GroupListPanel(String id) {
    super(id);/*from  w  w w . j a  v a2  s.  c o m*/
    GroupListModel groupListModel = new GroupListModel(new Group(""), SecUtils.getSession(this));
    setDefaultModel(groupListModel);
    addGrid();
    radioGroup = new RadioGroup("searchOptions", new PropertyModel(this, "selectedRadioButton"));
    add(radioGroup);
    Radio groupRb = new Radio("groupRb", new Model(Character.valueOf(NAMES)));
    radioGroup.add(groupRb);
    Radio memberRb = new Radio("memberRb", new Model(Character.valueOf(MEMBERS)));
    radioGroup.add(memberRb);
    addMemberSearchModal(memberRb);
    radioGroup.setOutputMarkupId(true);
    radioGroup.setRenderBodyOnly(false);
    searchValFld = new TextField(GlobalIds.SEARCH_VAL, new PropertyModel<String>(this, GlobalIds.SEARCH_VAL));
    searchValFld.setOutputMarkupId(true);
    AjaxFormComponentUpdatingBehavior ajaxUpdater = new AjaxFormComponentUpdatingBehavior(GlobalIds.ONBLUR) {
        /** Default serialVersionUID */
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            target.add(searchValFld);
        }
    };
    searchValFld.add(ajaxUpdater);
    radioGroup.add(searchValFld);

    this.listForm.add(radioGroup);
    selectedRadioButton = NAMES;

    this.listForm.add(new SecureIndicatingAjaxButton(GlobalIds.SEARCH, GlobalIds.GROUP_MGR, "find") {
        /** Default serialVersionUID */
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form form) {
            log.debug(".search.onSubmit selected radio button: " + selectedRadioButton);
            info("Searching Group Objects...");
            if (!StringUtils.isNotEmpty(searchVal)) {
                searchVal = "";
            }
            Group srchObject = new Group();
            switch (selectedRadioButton) {
            case NAMES:
                log.debug(".onSubmit GROUP RB selected");
                srchObject.setName(searchVal);
                break;
            case MEMBERS:
                log.debug(".onSubmit MEMBERS RB selected");
                srchObject.setMember(searchVal);
                break;
            }
            setDefaultModel(new GroupListModel(srchObject, SecUtils.getSession(this)));
            treeModel.reload();
            rootNode.removeAllChildren();
            List<Group> groups = (List<Group>) getDefaultModelObject();
            if (CollectionUtils.isNotEmpty(groups)) {
                for (Group group : groups)
                    rootNode.add(new DefaultMutableTreeNode(group));
                info("Search returned " + groups.size() + " matching objects");
            } else {
                info("No matching objects found");
            }
            target.add(grid);
        }

        @Override
        public void onError(AjaxRequestTarget target, Form form) {
            log.warn(".search.onError");
            target.add();
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            AjaxCallListener ajaxCallListener = new AjaxCallListener() {
                /** Default serialVersionUID */
                private static final long serialVersionUID = 1L;

                @Override
                public CharSequence getFailureHandler(Component component) {
                    return GlobalIds.WINDOW_LOCATION_REPLACE_COMMANDER_HOME_HTML;
                }
            };
            attributes.getAjaxCallListeners().add(ajaxCallListener);
        }
    });
}