Example usage for java.util.prefs Preferences MAX_VALUE_LENGTH

List of usage examples for java.util.prefs Preferences MAX_VALUE_LENGTH

Introduction

In this page you can find the example usage for java.util.prefs Preferences MAX_VALUE_LENGTH.

Prototype

int MAX_VALUE_LENGTH

To view the source code for java.util.prefs Preferences MAX_VALUE_LENGTH.

Click Source Link

Document

Maximum length of string allowed as a value (8192 characters).

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {

    // Get maximum key length
    int keyMax = Preferences.MAX_KEY_LENGTH;

    // Get maximum value length
    int valueMax = Preferences.MAX_VALUE_LENGTH;

    // Get maximum length of byte array values
    int bytesMax = Preferences.MAX_VALUE_LENGTH * 3 / 4;
}

From source file:com.vaadin.integration.maven.wscdn.CvalChecker.java

static void cacheLicenseInfo(CvalInfo info) {
    if (info != null) {
        Preferences p = Preferences.userNodeForPackage(CvalInfo.class);
        if (info.toString().length() > Preferences.MAX_VALUE_LENGTH) {
            // This should never happen since MAX_VALUE_LENGTH is big
            // enough.
            // But server could eventually send a very big message, so we
            // discard it in cache and would use hard-coded messages.
            info.setMessage(null);/*  www. jav a2 s  . c o m*/
        }
        p.put(info.getProduct().getName(), info.toString());
    }
}

From source file:org.openconcerto.sql.preferences.SQLPreferences.java

static private SQLCreateTable[] getCreateTables(final DBRoot root) throws SQLException {
    final SQLCreateTable createNodeT = new SQLCreateTable(root, PREF_NODE_TABLENAME);
    // don't need ORDER and ARCHIVE
    createNodeT.setPlain(true);/*from  w  w  w  .  j  ava2s.  co  m*/
    createNodeT.addColumn(SQLSyntax.ID_NAME, createNodeT.getSyntax().getPrimaryIDDefinition());
    // cannot use addForeignColumn() since it's a self-reference
    createNodeT.addColumn("ID_PARENT", createNodeT.getSyntax().getIDType() + " NULL");
    createNodeT.addVarCharColumn("NAME", Preferences.MAX_NAME_LENGTH);

    createNodeT.addForeignConstraint("ID_PARENT", new SQLName(createNodeT.getName()), SQLSyntax.ID_NAME);
    createNodeT.addUniqueConstraint("uniqNamePerParent", Arrays.asList("ID_PARENT", "NAME"));

    final SQLCreateTable createValueT = new SQLCreateTable(root, PREF_VALUE_TABLENAME);
    createValueT.setPlain(true);
    createValueT.addColumn("ID_NODE", createValueT.getSyntax().getIDType() + " NOT NULL");
    createValueT.addVarCharColumn("NAME", Preferences.MAX_KEY_LENGTH);
    createValueT.addVarCharColumn("VALUE", Preferences.MAX_VALUE_LENGTH, true);
    // unique name per node
    createValueT.setPrimaryKey("ID_NODE", "NAME");
    createValueT.addForeignConstraint("ID_NODE", new SQLName(createNodeT.getName()), SQLSyntax.ID_NAME);

    return new SQLCreateTable[] { createNodeT, createValueT };
}