Examples of XFile


Examples of com.nexirius.util.XFile

     * @param id the is of the instance
     * @return null if instance does not exist
     */
    public DataModel read(Class cl, String id) {
        try {
            XFile dir = getDirectory(cl);
            XFile file = new XFile(dir.getPath(), id);
            DataModel ret = (DataModel) cl.newInstance();
            ret.dropData(new String(file.getBytes()));
            ret.setInstanceName(id);
            return ret;
        } catch (Exception ex) {
            ex.printStackTrace();
        }
View Full Code Here

Examples of com.nexirius.util.XFile

     *
     * @param model
     */
    public void read(DataModel model) {
        try {
            XFile dir = getDirectory(model.getClass());
            XFile file = new XFile(dir.getPath(), model.getInstanceName());

            model.dropData(new String(file.getBytes()));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
View Full Code Here

Examples of com.nexirius.util.XFile

     * @return always returns a valid vector (which can be empty)
     */
    public SortedVector getAll(Class cl, String propertyName, String propertyValue) {
        SortedVector ret = new DataModelVector();
        try {
            XFile dir = getDirectory(cl);
            StringVector files = dir.getFiles(false); // get the list of all the files in this directory
            for (String id = files.firstItem(); id != null; id = files.nextItem()) {
                DataModel model = (DataModel) cl.newInstance(); //create a new instance of the given type
                XFile file = new XFile(dir.getPath(), id);
                model.dropData(new String(file.getBytes()));
                model.setInstanceName(id);
                if (propertyValue == null || propertyValue.equals(model.getChildText(propertyName))) {
                    ret.addElement(model);
                }
            }
View Full Code Here

Examples of com.nexirius.util.XFile

     *
     * @param model
     */
    public void update(DataModel model) {
        try {
            XFile dir = getDirectory(model.getClass());
            XFile file = new XFile(dir.getPath(), model.getInstanceName());
            file.writeText(model.dragData());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
View Full Code Here

Examples of com.nexirius.util.XFile

        }

        String urlDirectoryName = getDirectoryName('/', false);
        String dirUrl = sourceRootDirectoryUrl + urlDirectoryName;
        String directoryName = getDirectoryName(File.separatorChar, false);
        XFile targetDir = new XFile(targetRootDirectory + File.separatorChar + directoryName);

        // sync myself
        if (isCreate()) {
            dirSyncManager.createDirectory(targetDir);
        } else if (isRemove()) {
            dirSyncManager.removeDirectory(targetRootDirectory, directoryName);
            return;
        } else if (!targetDir.exists()) {
            dirSyncManager.createDirectory(targetDir);
        }

        // sync files
        DataModelEnumeration e = getFileList().getEnumeration();

        if (!targetDir.isDirectory()) {
            new Exception(targetDir.getPath() + " is not a target directory.").printStackTrace();
            return;
        }

        while (e.hasMore()) {
            if (dirSyncManager.isInterrupted()) {
View Full Code Here

Examples of com.nexirius.util.XFile

    public String getPath() {
        return getDirectoryName('/', true);
    }

    public void writeInfoToDirectory(String dirName) {
        XFile dir = new XFile(dirName);

        dir.mkdirs();
        dir.mkdir();

        XFile dirInfo = new XFile(dirName, DIR_INFO_FILENAME);

        if (dirList != null) {
            dirList.setTransient(true);
        }
View Full Code Here

Examples of com.nexirius.util.XFile

    public long getFiles() {
        return files.getLong();
    }

    public static void main(String argv[]) throws Exception {
        XFile targetDirectory = new XFile("C:\\temp\\foo2");
        XFile sourceDir = new XFile("C:\\temp\\Zahlungen");
        XFile infoDir = new XFile("C:\\temp\\infoDir");

//        targetDirectory.delete();
//        targetDirectory.mkdirs();
//        targetDirectory.mkdir();
        infoDir.delete();

        DirectoryInfoModel sourceModel = new DirectoryInfoModel(sourceDir.getPath(), "+\"*\"-\"*\"", "+\"*\"");
        sourceModel.writeInfoToDirectory(infoDir.getPath());

        DirectoryInfoModel infoModel = new DirectoryInfoModel(infoDir.toURL());
        DirectoryInfoModel targetModel = new DirectoryInfoModel(targetDirectory.getPath(), "+\"*\"", "+\"*\"");

        targetModel.compareTo(infoModel);


View Full Code Here

Examples of com.nexirius.util.XFile

    public void removeDirectory(String targetRootDirectory, String directoryName) {
        if (surplus == SURPLUS_IGNORE) {
            return ;
        }

        XFile targetDir = new XFile(targetRootDirectory + XFile.separator + directoryName);

        if (surplus == SURPLUS_TRASH) {
            XFile root = new XFile(targetRootDirectory);
            String parent = root.getParent();

            if (parent == null) {
                parent = root.getPath();
            }

            XFile trashDir = new XFile(parent, root.getName() + TRASH_POSTFIX);
            XFile targetTrashDir = new XFile(trashDir + XFile.separator + directoryName);

            targetTrashDir.getParentFile().mkdirs();


            targetDir.renameTo(targetTrashDir);
        } else {
            targetDir.delete();
View Full Code Here

Examples of com.nexirius.util.XFile

    public void removeFile(String targetRootDirectory, String directoryName, String fileName) {
        if (surplus == SURPLUS_IGNORE) {
            return ;
        }

        XFile targetFile = new XFile(targetRootDirectory + XFile.separator + directoryName, fileName);

        if (surplus == SURPLUS_TRASH) {
            XFile root = new XFile(targetRootDirectory);
            String parent = root.getParent();

            if (parent == null) {
                parent = root.getPath();
            }

            XFile trashDir = new XFile(parent, root.getName() + TRASH_POSTFIX);
            XFile targetTrashDir = new XFile(trashDir + XFile.separator + directoryName);

            targetTrashDir.mkdirs();

            XFile targetTrashFile = new XFile(targetTrashDir.getPath(), fileName);

            targetFile.renameTo(targetTrashFile);
        } else {
            targetFile.delete();
        }
View Full Code Here

Examples of com.nexirius.util.XFile

            return;
        }

        if (isCreate() || isChange()) {
            String targetDir = targetRootDirectory + XFile.separator + directoryName;
            XFile targetFile = new XFile(targetDir, getName());
            URL url = null;
            try {
                url = new URL(sourceDirUrl + '/' + getName());
                dirSyncManager.createFile(url, targetFile);
            } catch (MalformedURLException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.