Java 类java.util.prefs.InvalidPreferencesFormatException 实例源码

项目:javify    文件:NodeReader.java   
private void readRoot()
                throws InvalidPreferencesFormatException, IOException
{
    // Begin starting tag
    skipTill("<root");

    // type attribute
    skipTill("type=\"");
    String type = readTill("\"");
    Preferences root;
    if ("user".equals(type)) {
        root = factory.userRoot();
    } else if ("system".equals(type)) {
        root = factory.systemRoot();
    } else {
        throw new InvalidPreferencesFormatException("Unknown type: "
                                                    + type);
    }

    // Read root map and subnodes
    readMap(root);
    readNodes(root);

    // Ending tag
    skipTill("</root>");
}
项目:javify    文件:NodeReader.java   
private void readMap(Preferences node)
                throws InvalidPreferencesFormatException, IOException
{
    // Begin map tag
    skipTill("<map");

    // Empty map?
    if (line.startsWith("/>")) {
        line = line.substring(2);
        return;
    }

    // Map entries
    readEntries(node);

    // Ending tag
    skipTill("</map>");
}
项目:javify    文件:NodeReader.java   
private void skipTill(String s)
                throws InvalidPreferencesFormatException, IOException
{
    while(true) {
        if (line == null)
            throw new InvalidPreferencesFormatException(s + " not found");

        int index = line.indexOf(s);
        if (index == -1)  {
            line = br.readLine();
        } else {
            line = line.substring(index+s.length());
            return;
        }
    }
}
项目:javify    文件:NodeReader.java   
private String nextTag()
                throws InvalidPreferencesFormatException, IOException
{
    while(true) {
        if (line == null)
            throw new InvalidPreferencesFormatException("unexpected EOF");

        int start = line.indexOf("<");
        if (start == -1)  {
            line = br.readLine();
        } else {
            // Find end of tag
            int end = start+1;
            while (end != line.length()
                   && " \t\r\n".indexOf(line.charAt(end)) == -1) {
                end++;
            }
            // Line now starts at the found tag
            String tag = line.substring(start+1,end);
            line = line.substring(start);
            return tag;
        }
    }
}
项目:jvm-stm    文件:NodeReader.java   
private void readRoot()
                throws InvalidPreferencesFormatException, IOException
{
    // Begin starting tag
    skipTill("<root");

    // type attribute
    skipTill("type=\"");
    String type = readTill("\"");
    Preferences root;
    if ("user".equals(type)) {
        root = factory.userRoot();
    } else if ("system".equals(type)) {
        root = factory.systemRoot();
    } else {
        throw new InvalidPreferencesFormatException("Unknown type: "
                                                    + type);
    }

    // Read root map and subnodes
    readMap(root);
    readNodes(root);

    // Ending tag
    skipTill("</root>");
}
项目:jvm-stm    文件:NodeReader.java   
private void readMap(Preferences node)
                throws InvalidPreferencesFormatException, IOException
{
    // Begin map tag
    skipTill("<map");

    // Empty map?
    if (line.startsWith("/>")) {
        line = line.substring(2);
        return;
    }

    // Map entries
    readEntries(node);

    // Ending tag
    skipTill("</map>");
}
项目:jvm-stm    文件:NodeReader.java   
private void skipTill(String s)
                throws InvalidPreferencesFormatException, IOException
{
    while(true) {
        if (line == null)
            throw new InvalidPreferencesFormatException(s + " not found");

        int index = line.indexOf(s);
        if (index == -1)  {
            line = br.readLine();
        } else {
            line = line.substring(index+s.length());
            return;
        }
    }
}
项目:jvm-stm    文件:NodeReader.java   
private String nextTag()
                throws InvalidPreferencesFormatException, IOException
{
    while(true) {
        if (line == null)
            throw new InvalidPreferencesFormatException("unexpected EOF");

        int start = line.indexOf("<");
        if (start == -1)  {
            line = br.readLine();
        } else {
            // Find end of tag
            int end = start+1;
            while (end != line.length()
                   && " \t\r\n".indexOf(line.charAt(end)) == -1) {
                end++;
            }
            // Line now starts at the found tag
            String tag = line.substring(start+1,end);
            line = line.substring(start);
            return tag;
        }
    }
}
项目:java-scanner-access-twain    文件:XmlSupport.java   
static void importPreferences(InputStream is)
    throws IOException, InvalidPreferencesFormatException
{
    try {
        Document doc = loadPrefsDoc(is);
        String xmlVersion =
            doc.getDocumentElement().getAttribute("EXTERNAL_XML_VERSION");
        if (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0)
            throw new InvalidPreferencesFormatException(
            "Exported preferences file format version " + xmlVersion +
            " is not supported. This java installation can read" +
            " versions " + EXTERNAL_XML_VERSION + " or older. You may need" +
            " to install a newer version of JDK.");

        Element xmlRoot = (Element) doc.getDocumentElement().
                                           getChildNodes().item(0);
        Preferences prefsRoot =
            (xmlRoot.getAttribute("type").equals("user") ?
                        Preferences.userRoot() : Preferences.systemRoot());
        ImportSubtree(prefsRoot, xmlRoot);
    } catch(SAXException e) {
        throw new InvalidPreferencesFormatException(e);
    }
}
项目:java-scanner-access-twain    文件:XmlSupport.java   
static void importMap(InputStream is, Map m)
    throws IOException, InvalidPreferencesFormatException
{
    try {
        Document doc = loadPrefsDoc(is);
        Element xmlMap = doc.getDocumentElement();

        String mapVersion = xmlMap.getAttribute("MAP_XML_VERSION");
        if (mapVersion.compareTo(MAP_XML_VERSION) > 0)
            throw new InvalidPreferencesFormatException(
            "Preferences map file format version " + mapVersion +
            " is not supported. This java installation can read" +
            " versions " + MAP_XML_VERSION + " or older. You may need" +
            " to install a newer version of JDK.");

        NodeList entries = xmlMap.getChildNodes();
        for (int i=0, numEntries=entries.getLength(); i<numEntries; i++) {
            Element entry = (Element) entries.item(i);
            m.put(entry.getAttribute("key"), entry.getAttribute("value"));
        }
    } catch(SAXException e) {
        throw new InvalidPreferencesFormatException(e);
    }
}
项目:java-ocr-api    文件:XmlSupport.java   
static void importPreferences(InputStream is)
    throws IOException, InvalidPreferencesFormatException
{
    try {
        Document doc = loadPrefsDoc(is);
        String xmlVersion =
            doc.getDocumentElement().getAttribute("EXTERNAL_XML_VERSION");
        if (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0)
            throw new InvalidPreferencesFormatException(
            "Exported preferences file format version " + xmlVersion +
            " is not supported. This java installation can read" +
            " versions " + EXTERNAL_XML_VERSION + " or older. You may need" +
            " to install a newer version of JDK.");

        Element xmlRoot = (Element) doc.getDocumentElement().
                                           getChildNodes().item(0);
        Preferences prefsRoot =
            (xmlRoot.getAttribute("type").equals("user") ?
                        Preferences.userRoot() : Preferences.systemRoot());
        ImportSubtree(prefsRoot, xmlRoot);
    } catch(SAXException e) {
        throw new InvalidPreferencesFormatException(e);
    }
}
项目:java-ocr-api    文件:XmlSupport.java   
static void importMap(InputStream is, Map m)
    throws IOException, InvalidPreferencesFormatException
{
    try {
        Document doc = loadPrefsDoc(is);
        Element xmlMap = doc.getDocumentElement();

        String mapVersion = xmlMap.getAttribute("MAP_XML_VERSION");
        if (mapVersion.compareTo(MAP_XML_VERSION) > 0)
            throw new InvalidPreferencesFormatException(
            "Preferences map file format version " + mapVersion +
            " is not supported. This java installation can read" +
            " versions " + MAP_XML_VERSION + " or older. You may need" +
            " to install a newer version of JDK.");

        NodeList entries = xmlMap.getChildNodes();
        for (int i=0, numEntries=entries.getLength(); i<numEntries; i++) {
            Element entry = (Element) entries.item(i);
            m.put(entry.getAttribute("key"), entry.getAttribute("value"));
        }
    } catch(SAXException e) {
        throw new InvalidPreferencesFormatException(e);
    }
}
项目:JamVM-PH    文件:NodeReader.java   
private void readRoot()
                throws InvalidPreferencesFormatException, IOException
{
    // Begin starting tag
    skipTill("<root");

    // type attribute
    skipTill("type=\"");
    String type = readTill("\"");
    Preferences root;
    if ("user".equals(type)) {
        root = factory.userRoot();
    } else if ("system".equals(type)) {
        root = factory.systemRoot();
    } else {
        throw new InvalidPreferencesFormatException("Unknown type: "
                                                    + type);
    }

    // Read root map and subnodes
    readMap(root);
    readNodes(root);

    // Ending tag
    skipTill("</root>");
}
项目:JamVM-PH    文件:NodeReader.java   
private void readMap(Preferences node)
                throws InvalidPreferencesFormatException, IOException
{
    // Begin map tag
    skipTill("<map");

    // Empty map?
    if (line.startsWith("/>")) {
        line = line.substring(2);
        return;
    }

    // Map entries
    readEntries(node);

    // Ending tag
    skipTill("</map>");
}
项目:JamVM-PH    文件:NodeReader.java   
private void skipTill(String s)
                throws InvalidPreferencesFormatException, IOException
{
    while(true) {
        if (line == null)
            throw new InvalidPreferencesFormatException(s + " not found");

        int index = line.indexOf(s);
        if (index == -1)  {
            line = br.readLine();
        } else {
            line = line.substring(index+s.length());
            return;
        }
    }
}
项目:JamVM-PH    文件:NodeReader.java   
private String nextTag()
                throws InvalidPreferencesFormatException, IOException
{
    while(true) {
        if (line == null)
            throw new InvalidPreferencesFormatException("unexpected EOF");

        int start = line.indexOf("<");
        if (start == -1)  {
            line = br.readLine();
        } else {
            // Find end of tag
            int end = start+1;
            while (end != line.length()
                   && " \t\r\n".indexOf(line.charAt(end)) == -1) {
                end++;
            }
            // Line now starts at the found tag
            String tag = line.substring(start+1,end);
            line = line.substring(start);
            return tag;
        }
    }
}
项目:classpath    文件:NodeReader.java   
private void readRoot()
                throws InvalidPreferencesFormatException, IOException
{
    // Begin starting tag
    skipTill("<root");

    // type attribute
    skipTill("type=\"");
    String type = readTill("\"");
    Preferences root;
    if ("user".equals(type)) {
        root = factory.userRoot();
    } else if ("system".equals(type)) {
        root = factory.systemRoot();
    } else {
        throw new InvalidPreferencesFormatException("Unknown type: "
                                                    + type);
    }

    // Read root map and subnodes
    readMap(root);
    readNodes(root);

    // Ending tag
    skipTill("</root>");
}
项目:classpath    文件:NodeReader.java   
private void readMap(Preferences node)
                throws InvalidPreferencesFormatException, IOException
{
    // Begin map tag
    skipTill("<map");

    // Empty map?
    if (line.startsWith("/>")) {
        line = line.substring(2);
        return;
    }

    // Map entries
    readEntries(node);

    // Ending tag
    skipTill("</map>");
}
项目:classpath    文件:NodeReader.java   
private void skipTill(String s)
                throws InvalidPreferencesFormatException, IOException
{
    while(true) {
        if (line == null)
            throw new InvalidPreferencesFormatException(s + " not found");

        int index = line.indexOf(s);
        if (index == -1)  {
            line = br.readLine();
        } else {
            line = line.substring(index+s.length());
            return;
        }
    }
}
项目:classpath    文件:NodeReader.java   
private String nextTag()
                throws InvalidPreferencesFormatException, IOException
{
    while(true) {
        if (line == null)
            throw new InvalidPreferencesFormatException("unexpected EOF");

        int start = line.indexOf("<");
        if (start == -1)  {
            line = br.readLine();
        } else {
            // Find end of tag
            int end = start+1;
            while (end != line.length()
                   && " \t\r\n".indexOf(line.charAt(end)) == -1) {
                end++;
            }
            // Line now starts at the found tag
            String tag = line.substring(start+1,end);
            line = line.substring(start);
            return tag;
        }
    }
}
项目:jvarkit    文件:AbstractCGI.java   
protected Preferences getPreferences() throws IOException
{
if(this.prefs==null)
    {
    InputStream is=null;
    try
        {
        is=openPreferences();
        Preferences.importPreferences(is);
        }
    catch(InvalidPreferencesFormatException er)
        {
        throw new IOException(er);
        }
    finally
        {
        CloserUtil.close(is);
        }
    this.prefs=Preferences.userRoot();
    }
return this.prefs;
}
项目:javify    文件:NodeReader.java   
private void readPreferences()
                throws InvalidPreferencesFormatException, IOException
{
    // Begin starting tag
    skipTill("<preferences");

    readRoot();

    // Ending tag
    skipTill("</preferences>");
}
项目:javify    文件:NodeReader.java   
private void readNodes(Preferences node)
                throws InvalidPreferencesFormatException, IOException
{
    while ("node".equals(nextTag())) {
        skipTill("<node");
        skipTill("name=\"");
        String name = readTill("\"");
        Preferences subnode = node.node(name);
        readMap(subnode);
        readNodes(subnode);
        skipTill("</node>");
    }

}
项目:javify    文件:NodeReader.java   
private void readEntries(Preferences node)
                throws InvalidPreferencesFormatException, IOException
{
    while ("entry".equals(nextTag())) {
        skipTill("<entry");
        skipTill("key=\"");
        String key = readTill("\"");
        skipTill("value=\"");
        String value = readTill("\"");
        node.put(key, value);
    }
}
项目:javify    文件:NodeReader.java   
private String readTill(String s)
                throws InvalidPreferencesFormatException
{
    int index = line.indexOf(s);
    if (index == -1)
            throw new InvalidPreferencesFormatException(s + " not found");

    String read = line.substring(0, index);
    line = line.substring(index+s.length());

    return read;
}
项目:jvm-stm    文件:NodeReader.java   
private void readPreferences()
                throws InvalidPreferencesFormatException, IOException
{
    // Begin starting tag
    skipTill("<preferences");

    readRoot();

    // Ending tag
    skipTill("</preferences>");
}
项目:jvm-stm    文件:NodeReader.java   
private void readNodes(Preferences node)
                throws InvalidPreferencesFormatException, IOException
{
    while ("node".equals(nextTag())) {
        skipTill("<node");
        skipTill("name=\"");
        String name = readTill("\"");
        Preferences subnode = node.node(name);
        readMap(subnode);
        readNodes(subnode);
        skipTill("</node>");
    }

}
项目:jvm-stm    文件:NodeReader.java   
private void readEntries(Preferences node)
                throws InvalidPreferencesFormatException, IOException
{
    while ("entry".equals(nextTag())) {
        skipTill("<entry");
        skipTill("key=\"");
        String key = readTill("\"");
        skipTill("value=\"");
        String value = readTill("\"");
        node.put(key, value);
    }
}
项目:jvm-stm    文件:NodeReader.java   
private String readTill(String s)
                throws InvalidPreferencesFormatException
{
    int index = line.indexOf(s);
    if (index == -1)
            throw new InvalidPreferencesFormatException(s + " not found");

    String read = line.substring(0, index);
    line = line.substring(index+s.length());

    return read;
}
项目:cross-preferences    文件:PrefsController.java   
@RequestMapping(value = "/", method = RequestMethod.POST,
        consumes = {MediaType.TEXT_XML_VALUE, MediaType.APPLICATION_XML_VALUE})
@ResponseBody
ResponseEntity<Void> importPreferences(InputStream in) throws IOException, InvalidPreferencesFormatException {
    logger.info("Importing preferences from file...");
    Preferences.importPreferences(in);
    logger.info("Preferences import succeeded");
    return seeOtherResponse("/");
}
项目:gama    文件:GamaPreferences.java   
public static void applyPreferencesFrom(final String path, final Map<String, Object> modelValues) {
    // System.out.println("Apply preferences from " + path);
    try {
        final FileInputStream is = new FileInputStream(path);
        store.importPreferences(is);
        is.close();
        reloadPreferences(modelValues);
    } catch (final IOException | InvalidPreferencesFormatException e) {
        e.printStackTrace();
    }
}
项目:In-the-Box-Fork    文件:InvalidPreferencesFormatExceptionTest.java   
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "InvalidPreferencesFormatException",
    args = {java.lang.String.class}
)
public void testInvalidPreferencesFormatExceptionString() {
    InvalidPreferencesFormatException e = new InvalidPreferencesFormatException(
    "msg");
    assertNull(e.getCause());
    assertEquals("msg", e.getMessage());
}
项目:In-the-Box-Fork    文件:InvalidPreferencesFormatExceptionTest.java   
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "InvalidPreferencesFormatException",
    args = {java.lang.String.class, java.lang.Throwable.class}
)
public void testInvalidPreferencesFormatExceptionStringThrowable() {
    Throwable t = new Throwable("root");
    InvalidPreferencesFormatException e = new InvalidPreferencesFormatException(
            "msg", t);
    assertSame(t, e.getCause());
    assertTrue(e.getMessage().indexOf("root") < 0);
    assertTrue(e.getMessage().indexOf(t.getClass().getName()) < 0);
    assertTrue(e.getMessage().indexOf("msg") >= 0);
}
项目:In-the-Box-Fork    文件:InvalidPreferencesFormatExceptionTest.java   
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "InvalidPreferencesFormatException",
    args = {java.lang.Throwable.class}
)
public void testInvalidPreferencesFormatExceptionThrowable() {
    Throwable t = new Throwable("root");
    InvalidPreferencesFormatException e = new InvalidPreferencesFormatException(
            t);
    assertSame(t, e.getCause());
    assertTrue(e.getMessage().indexOf("root") >= 0);
    assertTrue(e.getMessage().indexOf(t.getClass().getName()) >= 0);
}
项目:In-the-Box-Fork    文件:InvalidPreferencesFormatExceptionTest.java   
/**
 * @tests serialization/deserialization.
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "Verifies serialization",
    method = "!SerializationSelf",
    args = {}
)
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new InvalidPreferencesFormatException(
    "msg"));
}
项目:In-the-Box-Fork    文件:InvalidPreferencesFormatExceptionTest.java   
/**
 * @tests serialization/deserialization compatibility with RI.
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "Verifies serialization",
    method = "!SerializationGolden",
    args = {}
)
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this,
            new InvalidPreferencesFormatException("msg"));
}
项目:cn1    文件:InvalidPreferencesFormatExceptionTest.java   
public void testInvalidPreferencesFormatExceptionStringThrowable() {
    Throwable t = new Throwable("root");
    InvalidPreferencesFormatException e = new InvalidPreferencesFormatException(
            "msg", t);
    assertSame(t, e.getCause());
    assertTrue(e.getMessage().indexOf("root") < 0);
    assertTrue(e.getMessage().indexOf(t.getClass().getName()) < 0);
    assertTrue(e.getMessage().indexOf("msg") >= 0);
}
项目:cn1    文件:InvalidPreferencesFormatExceptionTest.java   
public void testInvalidPreferencesFormatExceptionThrowable() {
    Throwable t = new Throwable("root");
    InvalidPreferencesFormatException e = new InvalidPreferencesFormatException(
            t);
    assertSame(t, e.getCause());
    assertTrue(e.getMessage().indexOf("root") >= 0);
    assertTrue(e.getMessage().indexOf(t.getClass().getName()) >= 0);
}
项目:JamVM-PH    文件:NodeReader.java   
private void readPreferences()
                throws InvalidPreferencesFormatException, IOException
{
    // Begin starting tag
    skipTill("<preferences");

    readRoot();

    // Ending tag
    skipTill("</preferences>");
}
项目:JamVM-PH    文件:NodeReader.java   
private void readNodes(Preferences node)
                throws InvalidPreferencesFormatException, IOException
{
    while ("node".equals(nextTag())) {
        skipTill("<node");
        skipTill("name=\"");
        String name = readTill("\"");
        Preferences subnode = node.node(name);
        readMap(subnode);
        readNodes(subnode);
        skipTill("</node>");
    }

}