Example usage for java.lang Character MAX_VALUE

List of usage examples for java.lang Character MAX_VALUE

Introduction

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

Prototype

char MAX_VALUE

To view the source code for java.lang Character MAX_VALUE.

Click Source Link

Document

The constant value of this field is the largest value of type char , '\u005CuFFFF' .

Usage

From source file:com.oneops.antenna.service.NotificationMessageDao.java

private List<String> getNsIds(String nsPath, NotificationType type) {
    String key = getOrgFromNsPath(nsPath);

    List<String> ids = new ArrayList<String>();
    SliceQuery<String, String, String> sliceQuery = HFactory.createSliceQuery(keyspace, stringSerializer,
            stringSerializer, stringSerializer);
    sliceQuery.setColumnFamily(NS_MAP_CF);
    sliceQuery.setRange(nsPath + Character.MIN_VALUE, nsPath + Character.MAX_VALUE, false, 1000000);
    sliceQuery.setKey(key);// w  w w  .  j  av a 2 s.  c o  m

    QueryResult<ColumnSlice<String, String>> result = sliceQuery.execute();
    ColumnSlice<String, String> resultCols = result.get();
    for (HColumn<String, String> col : resultCols.getColumns()) {
        String id = col.getValue();
        if (type == null) {
            ids.add(id);
        } else {
            if (type.equals(getTypeFromKey(id))) {
                ids.add(id);
            }
        }
    }
    return ids;
}

From source file:org.objectweb.proactive.core.body.ft.protocols.cic.managers.FTManagerCIC.java

@Override
public synchronized int onSendRequestBefore(Request request) {
    if (multiactiveLogger.isDebugEnabled()) {
        multiactiveLogger.debug("#onSendRequestBefore " + request.getMethodName());
    }//from  www .j a  v  a 2s. c o m
    if (!request.getMethodName().equals(FTManager.CHECKPOINT_METHOD_NAME)) {
        // set message info values
        this.forSentRequest.checkpointIndex = (char) this.checkpointIndex;
        this.forSentRequest.historyIndex = (char) this.historyIndex;
        this.forSentRequest.incarnation = (char) this.incarnation;
        this.forSentRequest.lastRecovery = (char) this.lastRecovery;
        this.forSentRequest.isOrphanFor = Character.MAX_VALUE;
        this.forSentRequest.fromHalfBody = false;
        if (FTManagerCIC.isOCEnable) {
            this.forSentRequest.vectorClock = this.localVectorClock;
        }
        request.setMessageInfo(this.forSentRequest);

        // output commit
        if (FTManagerCIC.isOCEnable && this.isOutputCommit(request)) {
            try {
                if (logger.isDebugEnabled()) {
                    logger.debug(this.ownerID + " is output commiting for request " + request);
                }
                this.storage.outputCommit(this.forSentRequest);
            } catch (RemoteException e) {
                logger.error("**ERROR** Cannot perform output commit");
                e.printStackTrace();
            }
        }
    }
    return 0;
}

From source file:com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.java

protected boolean isInRange(Number value, String stringValue, Class toType) {
    Number bigValue = null;/*from   w  ww .  j a  v  a 2  s  .  co m*/
    Number lowerBound = null;
    Number upperBound = null;

    try {
        if (double.class == toType || Double.class == toType) {
            bigValue = new BigDecimal(stringValue);
            // Double.MIN_VALUE is the smallest positive non-zero number
            lowerBound = BigDecimal.valueOf(Double.MAX_VALUE).negate();
            upperBound = BigDecimal.valueOf(Double.MAX_VALUE);
        } else if (float.class == toType || Float.class == toType) {
            bigValue = new BigDecimal(stringValue);
            // Float.MIN_VALUE is the smallest positive non-zero number
            lowerBound = BigDecimal.valueOf(Float.MAX_VALUE).negate();
            upperBound = BigDecimal.valueOf(Float.MAX_VALUE);
        } else if (byte.class == toType || Byte.class == toType) {
            bigValue = new BigInteger(stringValue);
            lowerBound = BigInteger.valueOf(Byte.MIN_VALUE);
            upperBound = BigInteger.valueOf(Byte.MAX_VALUE);
        } else if (char.class == toType || Character.class == toType) {
            bigValue = new BigInteger(stringValue);
            lowerBound = BigInteger.valueOf(Character.MIN_VALUE);
            upperBound = BigInteger.valueOf(Character.MAX_VALUE);
        } else if (short.class == toType || Short.class == toType) {
            bigValue = new BigInteger(stringValue);
            lowerBound = BigInteger.valueOf(Short.MIN_VALUE);
            upperBound = BigInteger.valueOf(Short.MAX_VALUE);
        } else if (int.class == toType || Integer.class == toType) {
            bigValue = new BigInteger(stringValue);
            lowerBound = BigInteger.valueOf(Integer.MIN_VALUE);
            upperBound = BigInteger.valueOf(Integer.MAX_VALUE);
        } else if (long.class == toType || Long.class == toType) {
            bigValue = new BigInteger(stringValue);
            lowerBound = BigInteger.valueOf(Long.MIN_VALUE);
            upperBound = BigInteger.valueOf(Long.MAX_VALUE);
        }
    } catch (NumberFormatException e) {
        //shoult it fail here? BigInteger doesnt seem to be so nice parsing numbers as NumberFormat
        return true;
    }

    return ((Comparable) bigValue).compareTo(lowerBound) >= 0
            && ((Comparable) bigValue).compareTo(upperBound) <= 0;
}

From source file:org.apache.tajo.engine.query.TestHBaseTable.java

@Test
public void testCompositeRowIndexPredication() throws Exception {

    executeString("CREATE TABLE hbase_mapped_table (rk text, rk2 text, col1 text, col2 text, col3 text) "
            + "TABLESPACE cluster1 USING hbase WITH ('table'='hbase_table', 'columns'='0:key,1:key,col1:a,col2:,col3:b', "
            + "'hbase.split.rowkeys'='010,040,060,080', " + "'hbase.rowkey.delimiter'='_')").close();

    assertTableExists("hbase_mapped_table");
    HBaseAdmin hAdmin = new HBaseAdmin(testingCluster.getHBaseUtil().getConf());
    hAdmin.tableExists("hbase_table");

    HTable htable = new HTable(testingCluster.getHBaseUtil().getConf(), "hbase_table");
    try {//from www .  j a v a  2  s. c  o  m
        org.apache.hadoop.hbase.util.Pair<byte[][], byte[][]> keys = htable.getStartEndKeys();
        assertEquals(5, keys.getFirst().length);

        DecimalFormat df = new DecimalFormat("000");
        for (int i = 0; i < 100; i++) {
            Put put = new Put((df.format(i) + "_" + df.format(i)).getBytes());
            put.add("col1".getBytes(), "a".getBytes(), ("a-" + i).getBytes());
            put.add("col1".getBytes(), "b".getBytes(), ("b-" + i).getBytes());
            put.add("col2".getBytes(), "k1".getBytes(), ("k1-" + i).getBytes());
            put.add("col2".getBytes(), "k2".getBytes(), ("k2-" + i).getBytes());
            put.add("col3".getBytes(), "b".getBytes(), ("b-" + i).getBytes());
            htable.put(put);
        }

        Scan scan = new Scan();
        scan.setStartRow("021".getBytes());
        scan.setStopRow(("021_" + new String(new char[] { Character.MAX_VALUE })).getBytes());
        Filter filter = new InclusiveStopFilter(scan.getStopRow());
        scan.setFilter(filter);

        ResultScanner scanner = htable.getScanner(scan);
        Result result = scanner.next();
        assertNotNull(result);
        assertEquals("021_021", new String(result.getRow()));
        scanner.close();

        assertIndexPredication(true);

        ResultSet res = executeString("select * from hbase_mapped_table where rk = '021'");
        String expected = "rk,rk2,col1,col2,col3\n" + "-------------------------------\n"
                + "021,021,a-21,{\"k1\":\"k1-21\", \"k2\":\"k2-21\"},b-21\n";

        assertEquals(expected, resultSetToString(res));
        res.close();
    } finally {
        executeString("DROP TABLE hbase_mapped_table PURGE").close();
        htable.close();
        hAdmin.close();
    }
}

From source file:org.apache.tajo.engine.query.TestHBaseTable.java

private void assertIndexPredication(boolean isCompositeRowKey) throws Exception {
    String postFix = isCompositeRowKey ? "_" + new String(new char[] { Character.MAX_VALUE }) : "";
    TableDesc tableDesc = catalog.getTableDesc(getCurrentDatabase(), "hbase_mapped_table");

    ScanNode scanNode = new ScanNode(1);

    // where rk = '021'
    EvalNode evalNodeEq = new BinaryEval(EvalType.EQUAL,
            new FieldEval(tableDesc.getLogicalSchema().getColumn("rk")), new ConstEval(new TextDatum("021")));
    scanNode.setQual(evalNodeEq);/*from  w ww  .ja  va  2  s .co m*/
    Tablespace tablespace = TablespaceManager.getByName("cluster1").get();
    List<Fragment> fragments = tablespace.getSplits("hbase_mapped_table", tableDesc, scanNode);
    assertEquals(1, fragments.size());
    assertEquals("021", new String(((HBaseFragment) fragments.get(0)).getStartRow()));
    assertEquals("021" + postFix, new String(((HBaseFragment) fragments.get(0)).getStopRow()));

    // where rk >= '020' and rk <= '055'
    EvalNode evalNode1 = new BinaryEval(EvalType.GEQ,
            new FieldEval(tableDesc.getLogicalSchema().getColumn("rk")), new ConstEval(new TextDatum("020")));
    EvalNode evalNode2 = new BinaryEval(EvalType.LEQ,
            new FieldEval(tableDesc.getLogicalSchema().getColumn("rk")), new ConstEval(new TextDatum("055")));
    EvalNode evalNodeA = new BinaryEval(EvalType.AND, evalNode1, evalNode2);
    scanNode.setQual(evalNodeA);

    fragments = tablespace.getSplits("hbase_mapped_table", tableDesc, scanNode);
    assertEquals(2, fragments.size());
    HBaseFragment fragment1 = (HBaseFragment) fragments.get(0);
    assertEquals("020", new String(fragment1.getStartRow()));
    assertEquals("040", new String(fragment1.getStopRow()));

    HBaseFragment fragment2 = (HBaseFragment) fragments.get(1);
    assertEquals("040", new String(fragment2.getStartRow()));
    assertEquals("055" + postFix, new String(fragment2.getStopRow()));

    // where (rk >= '020' and rk <= '055') or rk = '075'
    EvalNode evalNode3 = new BinaryEval(EvalType.EQUAL,
            new FieldEval(tableDesc.getLogicalSchema().getColumn("rk")), new ConstEval(new TextDatum("075")));
    EvalNode evalNodeB = new BinaryEval(EvalType.OR, evalNodeA, evalNode3);
    scanNode.setQual(evalNodeB);
    fragments = tablespace.getSplits("hbase_mapped_table", tableDesc, scanNode);
    assertEquals(3, fragments.size());
    fragment1 = (HBaseFragment) fragments.get(0);
    assertEquals("020", new String(fragment1.getStartRow()));
    assertEquals("040", new String(fragment1.getStopRow()));

    fragment2 = (HBaseFragment) fragments.get(1);
    assertEquals("040", new String(fragment2.getStartRow()));
    assertEquals("055" + postFix, new String(fragment2.getStopRow()));

    HBaseFragment fragment3 = (HBaseFragment) fragments.get(2);
    assertEquals("075", new String(fragment3.getStartRow()));
    assertEquals("075" + postFix, new String(fragment3.getStopRow()));

    // where (rk >= '020' and rk <= '055') or (rk >= '072' and rk <= '078')
    EvalNode evalNode4 = new BinaryEval(EvalType.GEQ,
            new FieldEval(tableDesc.getLogicalSchema().getColumn("rk")), new ConstEval(new TextDatum("072")));
    EvalNode evalNode5 = new BinaryEval(EvalType.LEQ,
            new FieldEval(tableDesc.getLogicalSchema().getColumn("rk")), new ConstEval(new TextDatum("078")));
    EvalNode evalNodeC = new BinaryEval(EvalType.AND, evalNode4, evalNode5);
    EvalNode evalNodeD = new BinaryEval(EvalType.OR, evalNodeA, evalNodeC);
    scanNode.setQual(evalNodeD);
    fragments = tablespace.getSplits("hbase_mapped_table", tableDesc, scanNode);
    assertEquals(3, fragments.size());

    fragment1 = (HBaseFragment) fragments.get(0);
    assertEquals("020", new String(fragment1.getStartRow()));
    assertEquals("040", new String(fragment1.getStopRow()));

    fragment2 = (HBaseFragment) fragments.get(1);
    assertEquals("040", new String(fragment2.getStartRow()));
    assertEquals("055" + postFix, new String(fragment2.getStopRow()));

    fragment3 = (HBaseFragment) fragments.get(2);
    assertEquals("072", new String(fragment3.getStartRow()));
    assertEquals("078" + postFix, new String(fragment3.getStopRow()));

    // where (rk >= '020' and rk <= '055') or (rk >= '057' and rk <= '059')
    evalNode4 = new BinaryEval(EvalType.GEQ, new FieldEval(tableDesc.getLogicalSchema().getColumn("rk")),
            new ConstEval(new TextDatum("057")));
    evalNode5 = new BinaryEval(EvalType.LEQ, new FieldEval(tableDesc.getLogicalSchema().getColumn("rk")),
            new ConstEval(new TextDatum("059")));
    evalNodeC = new BinaryEval(EvalType.AND, evalNode4, evalNode5);
    evalNodeD = new BinaryEval(EvalType.OR, evalNodeA, evalNodeC);
    scanNode.setQual(evalNodeD);
    fragments = tablespace.getSplits("hbase_mapped_table", tableDesc, scanNode);
    assertEquals(2, fragments.size());

    fragment1 = (HBaseFragment) fragments.get(0);
    assertEquals("020", new String(fragment1.getStartRow()));
    assertEquals("040", new String(fragment1.getStopRow()));

    fragment2 = (HBaseFragment) fragments.get(1);
    assertEquals("040", new String(fragment2.getStartRow()));
    assertEquals("059" + postFix, new String(fragment2.getStopRow()));
}

From source file:org.ajax4jsf.application.AjaxStateManager.java

/**
 * Return logical Id for current request view state. For a faces requests,
 * generate sequence numbers. For a ajax request, attempt to re-use id from
 * request submit./*  w w w  . j  a va  2 s.  co  m*/
 * 
 * @param context
 * @return
 */
protected String getLogicalViewId(FacesContext context) {
    AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
    ExternalContext externalContext = context.getExternalContext();
    Object id = null;
    Map<String, Object> requestMap = externalContext.getRequestMap();
    id = requestMap.get(ajaxContext.isAjaxRequest() ? AJAX_VIEW_SEQUENCE : VIEW_SEQUENCE);
    if (null != id) {
        return id.toString();
    }
    // Store sequence in session, to avoyd claster configuration problem
    // see https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=662
    Object session = externalContext.getSession(true);
    int viewSequence;
    synchronized (session) {
        Map<String, Object> sessionMap = externalContext.getSessionMap();
        Integer sequence = (Integer) sessionMap.get(VIEW_SEQUENCE_ATTRIBUTE);
        if (null != sequence) {
            viewSequence = sequence.intValue();
        } else {
            viewSequence = 0;
        }
        if (viewSequence++ == Character.MAX_VALUE) {
            viewSequence = 0;
        }
        sessionMap.put(VIEW_SEQUENCE_ATTRIBUTE, new Integer(viewSequence));
    }
    String logicalViewId = UIViewRoot.UNIQUE_ID_PREFIX + ((int) viewSequence);
    // Store new viewId in the request parameters, to avoid re-increments in the same request.
    requestMap.put(VIEW_SEQUENCE, logicalViewId);
    return logicalViewId;
}

From source file:org.openanzo.client.cli.CommandContext.java

private static boolean isUsed(String prefix, String[] sortedNodes, int length) {
    int low = Arrays.binarySearch(sortedNodes, prefix + (char) 0);
    int high = Arrays.binarySearch(sortedNodes, prefix + Character.MAX_VALUE);
    if (low < 0 && low == high)
        return false;
    return true;//w w w . jav  a2 s. c o  m
}

From source file:org.apache.felix.webconsole.internal.compendium.ConfigManager.java

private void printOptionsForm(PrintWriter printWriter, SortedMap inputOptions, String formId,
        String submitMethod, String submitLabel) {
    SortedSet tempSet = new TreeSet();
    for (Iterator entryIter = inputOptions.entrySet().iterator(); entryIter.hasNext();) {
        Entry tempEntry = (Entry) entryIter.next();
        tempSet.add(tempEntry.getValue().toString() + Character.MAX_VALUE + tempEntry.getKey().toString());
    }// w  w w . j  a va2 s.  co  m

    printWriter.println(
            "<select class='select' name='pid' id='" + formId + "' onChange='" + submitMethod + "();'>");
    for (Iterator treeIter = tempSet.iterator(); treeIter.hasNext();) {
        String nextEntry = (String) treeIter.next();
        int specChar = nextEntry.indexOf(Character.MAX_VALUE);
        String partialEntry = nextEntry.substring(0, specChar);
        String entryKey = nextEntry.substring(specChar + STRING_FORWARD);
        printWriter.print("<option value='" + entryKey + "'>");
        printWriter.print(partialEntry);
        printWriter.println("</option>");
    }
    printWriter.println("</select>");
    printWriter.println("&nbsp;&nbsp;");
    printWriter.println("<input class='submit' type='button' value='" + submitLabel + "' onClick='"
            + submitMethod + "();' />");

}

From source file:org.apache.tajo.storage.hbase.HBaseTablespace.java

public Pair<Datum, Datum> getIndexablePredicateValue(ColumnMapping columnMapping, Set<EvalNode> evalNodes) {
    Datum startDatum = null;//w  ww . j  a  va 2 s. c  o m
    Datum endDatum = null;
    for (EvalNode evalNode : evalNodes) {
        if (evalNode instanceof BinaryEval) {
            BinaryEval binaryEval = (BinaryEval) evalNode;
            EvalNode left = binaryEval.getLeftExpr();
            EvalNode right = binaryEval.getRightExpr();

            Datum constValue = null;
            if (left.getType() == EvalType.CONST) {
                constValue = ((ConstEval) left).getValue();
            } else if (right.getType() == EvalType.CONST) {
                constValue = ((ConstEval) right).getValue();
            }

            if (constValue != null) {
                if (evalNode.getType() == EvalType.EQUAL || evalNode.getType() == EvalType.GEQ
                        || evalNode.getType() == EvalType.GTH) {
                    if (startDatum != null) {
                        if (constValue.compareTo(startDatum) > 0) {
                            startDatum = constValue;
                        }
                    } else {
                        startDatum = constValue;
                    }
                }

                if (evalNode.getType() == EvalType.EQUAL || evalNode.getType() == EvalType.LEQ
                        || evalNode.getType() == EvalType.LTH) {
                    if (endDatum != null) {
                        if (constValue.compareTo(endDatum) < 0) {
                            endDatum = constValue;
                        }
                    } else {
                        endDatum = constValue;
                    }
                }
            }
        } else if (evalNode instanceof BetweenPredicateEval) {
            BetweenPredicateEval betweenEval = (BetweenPredicateEval) evalNode;
            if (betweenEval.getBegin().getType() == EvalType.CONST
                    && betweenEval.getEnd().getType() == EvalType.CONST) {
                Datum value = ((ConstEval) betweenEval.getBegin()).getValue();
                if (startDatum != null) {
                    if (value.compareTo(startDatum) > 0) {
                        startDatum = value;
                    }
                } else {
                    startDatum = value;
                }

                value = ((ConstEval) betweenEval.getEnd()).getValue();
                if (endDatum != null) {
                    if (value.compareTo(endDatum) < 0) {
                        endDatum = value;
                    }
                } else {
                    endDatum = value;
                }
            }
        }
    }

    if (endDatum != null && columnMapping != null && columnMapping.getNumRowKeys() > 1) {
        endDatum = new TextDatum(endDatum.asChars()
                + new String(new char[] { columnMapping.getRowKeyDelimiter(), Character.MAX_VALUE }));
    }
    if (startDatum != null || endDatum != null) {
        return new Pair<>(startDatum, endDatum);
    } else {
        return null;
    }
}

From source file:org.apache.tajo.storage.hbase.HBaseStorageManager.java

public Pair<Datum, Datum> getIndexablePredicateValue(ColumnMapping columnMapping, Set<EvalNode> evalNodes) {
    Datum startDatum = null;//from ww w. ja va 2 s .com
    Datum endDatum = null;
    for (EvalNode evalNode : evalNodes) {
        if (evalNode instanceof BinaryEval) {
            BinaryEval binaryEval = (BinaryEval) evalNode;
            EvalNode left = binaryEval.getLeftExpr();
            EvalNode right = binaryEval.getRightExpr();

            Datum constValue = null;
            if (left.getType() == EvalType.CONST) {
                constValue = ((ConstEval) left).getValue();
            } else if (right.getType() == EvalType.CONST) {
                constValue = ((ConstEval) right).getValue();
            }

            if (constValue != null) {
                if (evalNode.getType() == EvalType.EQUAL || evalNode.getType() == EvalType.GEQ
                        || evalNode.getType() == EvalType.GTH) {
                    if (startDatum != null) {
                        if (constValue.compareTo(startDatum) > 0) {
                            startDatum = constValue;
                        }
                    } else {
                        startDatum = constValue;
                    }
                }

                if (evalNode.getType() == EvalType.EQUAL || evalNode.getType() == EvalType.LEQ
                        || evalNode.getType() == EvalType.LTH) {
                    if (endDatum != null) {
                        if (constValue.compareTo(endDatum) < 0) {
                            endDatum = constValue;
                        }
                    } else {
                        endDatum = constValue;
                    }
                }
            }
        } else if (evalNode instanceof BetweenPredicateEval) {
            BetweenPredicateEval betweenEval = (BetweenPredicateEval) evalNode;
            if (betweenEval.getBegin().getType() == EvalType.CONST
                    && betweenEval.getEnd().getType() == EvalType.CONST) {
                Datum value = ((ConstEval) betweenEval.getBegin()).getValue();
                if (startDatum != null) {
                    if (value.compareTo(startDatum) > 0) {
                        startDatum = value;
                    }
                } else {
                    startDatum = value;
                }

                value = ((ConstEval) betweenEval.getEnd()).getValue();
                if (endDatum != null) {
                    if (value.compareTo(endDatum) < 0) {
                        endDatum = value;
                    }
                } else {
                    endDatum = value;
                }
            }
        }
    }

    if (endDatum != null && columnMapping != null && columnMapping.getNumRowKeys() > 1) {
        endDatum = new TextDatum(endDatum.asChars()
                + new String(new char[] { columnMapping.getRowKeyDelimiter(), Character.MAX_VALUE }));
    }
    if (startDatum != null || endDatum != null) {
        return new Pair<Datum, Datum>(startDatum, endDatum);
    } else {
        return null;
    }
}