当前位置: 首页>>代码示例>>Java>>正文


Java VilException.ID_IO属性代码示例

本文整理汇总了Java中net.ssehub.easy.instantiation.core.model.common.VilException.ID_IO属性的典型用法代码示例。如果您正苦于以下问题:Java VilException.ID_IO属性的具体用法?Java VilException.ID_IO怎么用?Java VilException.ID_IO使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在net.ssehub.easy.instantiation.core.model.common.VilException的用法示例。


在下文中一共展示了VilException.ID_IO属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: instantiate

/**
 * Instantiates the given XVCL specification file via VIL.
 * @param specification The stating point for instantiation with XVCL.
 * @throws VilException If XVCL detects any errors.
 */
void instantiate(FileArtifact specification) throws VilException {
    XVCLProcessor xvcl = new XVCLProcessor();
    String[] args = null;
    if (null != specification && null != specification.getPath()) {
        File specFile = specification.getPath().getAbsolutePath();
        if (null != specFile && null != specFile.getAbsolutePath()) {
            args = new String[]{specFile.getAbsolutePath()};
        }
    }
    
    // Critical: If xvcl detects any errors, it will call System.exit(1) and close the whole jVM.
    if (null != args && args.length > 0) {
        try {
            xvcl.process(args, true, true, false);
            xvcl.clearCache();
            System.out.println(xvcl.getVersion());

        } catch (XVCLException e) {
            throw new VilException(e, VilException.ID_IO);
        }
    }
    
    xvcl = null;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:29,代码来源:XvclTransformatorEngine.java

示例2: deleteAll

/**
 * Deletes all files in the given path.
 * 
 * @throws VilException in case of I/O problems
 */
public void deleteAll() throws VilException {
    if (isPattern()) {
        Set<FileArtifact> all = selectAll();
        if (null != all) {
            for (FileArtifact f : all) {
                f.delete();
            }
        }
    } else {
        try {
            File file = getAbsolutePath();
            if (!file.isFile()) {
                org.apache.commons.io.FileUtils.cleanDirectory(file);
            }
        } catch (IOException e) {
            throw new VilException(e, VilException.ID_IO);
        }
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:24,代码来源:Path.java

示例3: create

/**
 * Creates a temporary file artifact.
 * 
 * @return the created file artifact
 * @throws VilException in case that the creation fails
 */
public static FileArtifact create() throws VilException {
    try {
        File file = File.createTempFile("fileArtifact", "vil");
        file.deleteOnExit();
        FileArtifact result = ArtifactFactory.createArtifact(FileArtifact.class, file, null);
        result.isTemporary = true;
        return result;
    } catch (IOException e) {
        throw new VilException(e, VilException.ID_IO);
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:17,代码来源:FileArtifact.java

示例4: updateContents

/**
 * Updates the text contents.
 * 
 * @throws VilException in case that reading fails for some reason
 */
public void updateContents() throws VilException {
    if (isModifiable()) {
        if (null != file) {
            try {
                data = FileUtils.readFileToByteArray(file);
            } catch (IOException e) {
                throw new VilException(e, VilException.ID_IO);
            }
        }
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:16,代码来源:Binary.java

示例5: updateContents

@Override
public void updateContents() throws VilException {
    if (null != file && file.exists()) {           
        try {
            text = FileUtils.readFileToString(file);
        } catch (IOException e) {
            throw new VilException(e, VilException.ID_IO);
        }
    } else {
        text = "";
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:12,代码来源:Text.java

示例6: create

/**
 * Creates a temporary file artifact.
 * 
 * @return the created file artifact
 * @throws VilException in case that the creation fails
 */
public static FileArtifact create() throws VilException {
    try {
        File file = File.createTempFile("xmlFileArtifact", "vil");
        file.deleteOnExit();
        return ArtifactFactory.createArtifact(XmlFileArtifact.class, file, null);
    } catch (IOException e) {
        throw new VilException(e, VilException.ID_IO);
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:15,代码来源:XmlFileArtifact.java

示例7: mkdir

/**
 * Creates the directories pointing to path.
 * 
 * @throws VilException in case of a pattern path or if access to the absolute path fails
 */
public void mkdir() throws VilException {
    if (isPattern()) {
        throw new VilException("cannot create a directory from the pattern '" + path + "'", 
            VilException.ID_IO);
    }
    getAbsolutePath().mkdirs();
    ArtifactFactory.createArtifact(getAbsolutePath());
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:13,代码来源:Path.java

示例8: create

/**
 * Creates a temporary file artifact.
 * 
 * @return the created file artifact
 * @throws VilException in case that the creation fails
 */
public static FolderArtifact create() throws VilException {
    try { 
        File file = File.createTempFile("folderArtifact", "");
        file.delete();
        file.mkdirs();
        file.deleteOnExit();
        FolderArtifact result = ArtifactFactory.createArtifact(FolderArtifact.class, file, null);
        result.isTemporary = true;
        return result;
    } catch (IOException e) {
        throw new VilException(e, VilException.ID_IO);
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:19,代码来源:FolderArtifact.java

示例9: add

/**
 * Packs <code>source</code> files into <code>target</code> using handler.
 * 
 * @param base the base path used to make the paths of the <code>artifacts</code> relative, may
 *   be the source or target project
 * @param artifacts the artifacts to be handled
 * @param target the target ZIP/JAR file
 * @param handler the actual ZIP handler
 * @return the created artifacts
 * @throws VilException in case that processing the JAR file fails for some reason
 */
@Invisible
public static Set<FileArtifact> add(Path base, Collection<FileArtifact> artifacts, Path target, ZipHandler handler) 
    throws VilException {
    List<File> files = toFileList(artifacts);
    List<File> zipResult;
    try {
        zipResult = handler.add(base.getAbsolutePath(), files, target.getAbsolutePath());
    } catch (IOException e) {
        throw new VilException(e, VilException.ID_IO);
    }
    return toFileArtifactSet(zipResult, target.getArtifactModel());
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:23,代码来源:Zip.java

示例10: process

/**
 * Instantiates <code>source</code> to <code>target</code>.
 * 
 * @param template the input template script (as artifact)
 * @param config the variability configuration to process
 * @param target the target artifact (may be modified)
 * @param other named optional parameter
 * @param result the created artifacts (modified as a side effect)
 * @throws VilException in case that execution fails
 */
@OperationMeta(returnGenerics = IArtifact.class)
private static void process(VtlFileArtifact template, Configuration config, 
    IArtifact target, Map<String, Object> other, List<IArtifact> result) throws VilException {
    // obtaining the model info
    Path path = template.getPath();
    if (path.isPattern()) {
        throw new VilException("template '" + path.getPath() + "' is a pattern and cannot be instantiated", 
            VilException.ID_IO);
    } 
    File absPath = template.getPath().getAbsolutePath();
    if (!path.exists()) {
        throw new VilException("template '" + path.getPath() + "' (" + absPath + ") does not exist", 
            VilException.ID_IO);
    }
    URI uri = template.getPath().getAbsolutePath().toURI();
    ModelInfo<Template> info = TemplateModel.INSTANCE.availableModels().getInfo(uri);
    if (null == info) {
        throw new VilException("template '" + path.getPath() + "' does not contain a valid template model", 
            VilException.ID_IO);
    }
    // obtaining/loading the model
    try {
        Template model = TemplateModel.INSTANCE.load(info);
        process(model, config, target, other, result);
    } catch (ModelManagementException e) {
        throw new VilException(e.getMessage(), VilException.ID_IO);
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:38,代码来源:VilTemplateProcessor.java

示例11: unpack

/**
 * Unpacks files in <code>zip</code> into <code>target</code>.
 * 
 * @param zip the ZIP file to be unpacked
 * @param target the target path to unpack to
 * @param handler the ZIP/JAR handler
 * @return the created artifacts
 * @throws VilException in case of unpacking problems
 */
@Invisible
public static Set<FileArtifact> unpack(Path zip, Path target, ZipHandler handler) throws VilException {
    List<File> files = new ArrayList<File>();
    try {
        handler.unpack(zip.getAbsolutePath(), target.getAbsolutePath(), null, files);
    } catch (IOException e) {
        throw new VilException(e, VilException.ID_IO);
    }
    return Zip.toFileArtifactSet(files, target.getArtifactModel());
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:19,代码来源:Unzip.java

示例12: touch

/**
 * Just touches the given artifact.
 * 
 * @param artifact the artifact to be touched 
 * @return the touched artifact(s)
 * @throws VilException in case that the execution fails
 */
@OperationMeta(returnGenerics = IFileSystemArtifact.class)
public static Set<IArtifact> touch(IFileSystemArtifact artifact) throws VilException {
    File file = artifact.getPath().getAbsolutePath();
    try {
        FileUtils.touch(file);
    } catch (IOException e) {
        throw new VilException(e.getMessage(), VilException.ID_IO);
    }
    IArtifact[] result = new IArtifact[1];
    result[0] = artifact;
    return new ArraySet<IArtifact>(result, IArtifact.class);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:19,代码来源:TouchInstantiator.java

示例13: javac

/**
 * Compiles a source path to a target path.
 * 
 * @param source the source artifacts
 * @param target the target path
 * @param other the other parameter for the Java compiler, without leading "-"
 * @return the created artifacts
 * @throws VilException in case that artifact creation fails
 */
@OperationMeta(returnGenerics = FileArtifact.class)
public static Set<FileArtifact> javac(Collection<FileArtifact> source, Path target, Map<String, Object> other) 
    throws VilException {
    long timestamp = PathUtils.normalizedTime();
    JavaCompiler compiler = getJavaCompiler();
    StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
    if (source.isEmpty()) {
        throw new VilException("no source files to compile", VilException.ID_INSUFFICIENT_ARGUMENT);
    }
    List<File> files = new ArrayList<File>();
    for (FileArtifact fa : source) {
        files.add(fa.getPath().getAbsolutePath());
    }
    List<String> options = new ArrayList<String>();
    File targetPath = determineTargetPath(target);
    if (null != targetPath) {
        options.add("-d");
        options.add(targetPath.getAbsolutePath());
    }
    for (Map.Entry<String, Object> param : other.entrySet()) {
        options.add("-" + param.getKey());
        String val = toString(param.getValue());
        /*if (val.contains(" ")) {
            val = "\"" + val + "\"";
        }*/
        options.add(val);
    }

    StringWriter writer = new StringWriter();
    Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjectsFromFiles(files);
    boolean success = compiler.getTask(writer, fileManager, null, options, null, compilationUnits).call();
    try {
        fileManager.close(); 
    } catch (IOException e) {
        throw new VilException(e.getMessage(), VilException.ID_IO);
    }
    if (!success) {
        throw new VilException(writer.toString(), VilException.ID_RUNTIME_EXECUTION);
    }

    List<FileArtifact> result = new ArrayList<FileArtifact>();
    ScanResult<FileArtifact> scanResult = new ScanResult<FileArtifact>(result);
    FileUtils.scan(targetPath.getAbsoluteFile(), target.getArtifactModel(), timestamp, scanResult, 
        FileArtifact.class);
    scanResult.checkForException();
    return new ListSet<FileArtifact>(result, FileArtifact.class);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:56,代码来源:Javac.java

示例14: copyOrMove

/**
 * Copy or move from <code>source</code> to <code>target</code> considering each as directories 
 * or files. This method informs the involved artifact models appropriately.
 * 
 * @param source the source to copy from
 * @param target the target to copy to
 * @param sourceModel the source artifact model (may be <b>null</b> for copy, non-null for move operation)
 * @param targetModel the target artifact model
 * @param artifacts the created or touched artifacts (may be <b>null</b> then resulting artifacts will not be 
 *     collected)
 * @throws VilException in case that file system operations or artifact model operations fail
 */
private static void copyOrMove(File source, File target, ArtifactModel sourceModel, ArtifactModel targetModel, 
    List<IFileSystemArtifact> artifacts) throws VilException {
    if (source.isDirectory()) {
        if (target.isFile()) {
            target = target.getParentFile();
        }
        File[] files = source.listFiles();
        if (null != files) {
            for (File f: files) {
                if (f.isDirectory()) {
                    target = new File(target, f.getName());
                    target.mkdir();
                }
                copyOrMove(f, target, sourceModel, targetModel, artifacts);
            }
        }
    } else {
        boolean move = (null != sourceModel);
        if (move) {
            sourceModel.delete(source);
        }
        try {
            if (target.isDirectory()) {
                if (move) {
                    org.apache.commons.io.FileUtils.moveFileToDirectory(source, target, true);
                } else {
                    org.apache.commons.io.FileUtils.copyFileToDirectory(source, target, false);
                }
                target = new File(target, source.getName());
            } else {
                if (move) {
                    org.apache.commons.io.FileUtils.moveFile(source, target);
                } else {
                    org.apache.commons.io.FileUtils.copyFile(source, target, false);
                }
            }
        } catch (IOException e) {
            throw new VilException(e, VilException.ID_IO);
        }
        IFileSystemArtifact artifact = ArtifactFactory.createArtifact(IFileSystemArtifact.class, 
            target, targetModel);
        if (null != artifacts) {
            artifacts.add(artifact);
        }
        
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:59,代码来源:FileUtils.java


注:本文中的net.ssehub.easy.instantiation.core.model.common.VilException.ID_IO属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。