Package com.nexirius.util

Examples of com.nexirius.util.XFile


        public void doAction() {
            System.out.println("About");
            StringModel about = new StringModel("");
            try {
                XFile aboutFile = new XFile("EditProperties.htm");

                about.setText(new String(aboutFile.getBytes()));
            } catch (Exception ex) {
                about.setText(ex.getClass().getName());
                ex.printStackTrace();
            }
View Full Code Here


    StringVector getFiles(String rootDirectory, boolean reload)
            throws Exception {
        String ext = (this.extension == null ? FileSystemPersistence.DEFAULT_FILE_EXTENSION : this.extension);

        String dir = getDirectory(rootDirectory);
        XFile xf = new XFile(dir);

        if (!xf.exists() || !xf.isDirectory()) {
            throw new Exception("Directory '" + dir + "' does not exist");
        }

        if (files == null || reload) {
            files = xf.getFiles(false, "*" + ext);
        }

        return files;
    }
View Full Code Here

     * Creates the associated directory (rootDirectory is only used if relative == false)
     */
    public void createDirectory(String rootDirectory)
            throws Exception {
        String dir = getDirectory(rootDirectory);
        XFile file = new XFile(dir);

        if (file.exists()) {
            if (!file.isDirectory()) {
                throw new Exception("Can't create directory '" + dir + "' because this name corresponds to an existing file");
            }
        } else if (!file.mkdirs()) {
            throw new Exception("Can't create directory '" + dir + "'");
        }
    }
View Full Code Here

    public EntryArrayModel() {
        super(new EntryModel(), FIELD_NAME);
    }

    public void readEntries(String filename) throws Exception {
        XFile file = new XFile(filename);

        StringVector lines = file.getTextLines();

        for (String line = lines.firstItem(); line != null; line = lines.nextItem()) {
            EntryModel entry = new EntryModel();

            if (entry.parse(line)) {
View Full Code Here

            }
        }
    }

    public void saveTo(String filename, String locale) throws Exception {
        XFile file = new XFile(filename);
        DataModelEnumeration e = getEnumeration();
        StringVector lines = new StringVector();

        while (e.hasMore()) {
            EntryModel entry = (EntryModel) e.next();

            String line = entry.getLine(locale);

            if (line != null) {
                lines.append(line);
            }
        }

        file.writeTextLines(lines);
    }
View Full Code Here

    }


    private void readLocaleEntries(String fileName) throws Exception {
        // find locale files
        XFile directory = new XFile(getDirectory(fileName));
        StringVector files = directory.getFiles(true, "*.properties");
        String baseFileName = getBaseFileName(fileName);

        for (String localeFile = files.firstItem(); localeFile != null; localeFile = files.nextItem()) {
            localeFile = getDirectory(fileName) + localeFile;
            if (XString.match(baseFileName + "_*", localeFile)) {
View Full Code Here

            }
        }
    }

    private void parseLocaleFile(String localeFile, String locale) throws Exception {
        XFile file = new XFile(localeFile);
        StringVector lines = file.getTextLines();

        for (String line = lines.firstItem(); line != null; line = lines.nextItem()) {
            EntryModel newEntry = new EntryModel();

            newEntry.parse(line);
View Full Code Here

                    return;
                }
            }
        }

        writeFile(fileName, new XFile(fileName), null);

        DataModelEnumeration en = settings.getLocaleArrayModel().getEnumeration();

        while (en.hasMore()) {
            LocaleModel lm = (LocaleModel) en.next();
            String locale = lm.getFileExtension();
            XFile file = new XFile(getFilename(fileName, locale));

            writeFile(fileName, file, locale);
        }

        openFileName = fileName;
View Full Code Here

TOP

Related Classes of com.nexirius.util.XFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.