/** * Parse the file. * * @param file the virtual file to parse * @return new metadata instance * @throws Exception for any error */ protected T parse(VirtualFile file) throws Exception { if (file == null) throw new IllegalArgumentException("Null file"); InputSource source = new VFSInputSource(file); return getHelper().parse(source); } }
protected <U> U parse(Class<U> expectedType, VirtualFile file, Object root) throws Exception { U tRoot; if (root != null && expectedType.isInstance(root)) tRoot = expectedType.cast(root); else tRoot = null; ObjectModelFactory objectModelFactory = getObjectModelFactory(expectedType, file, tRoot); if (objectModelFactory == null) log.warn("ObjectModelFactory factory is null, expectedType=" + expectedType + ", file=" + file); InputSource source = new VFSInputSource(file); return getHelper().parse(expectedType, source, tRoot, objectModelFactory); }
protected <U> U parse(Class<U> expectedType, VirtualFile file, Object root) throws Exception { InputSource source = new VFSInputSource(file); return getHelper().parse(expectedType, source); } }
@Override protected T parse(VFSDeploymentUnit unit, VirtualFile file, T root) throws Exception { if (file == null) throw new IllegalArgumentException("Null file"); log.debugf("Parsing: %1s", file.getName()); Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setEventHandler(validationEventHandler); Schema schema = SchemaHelper.getSchema(schemaLocation); if (schema != null) unmarshaller.setSchema(schema); InputSource source = new VFSInputSource(file); Object result = unmarshaller.unmarshal(source); return getOutput().cast(result); } }
/** * Do the parsing * * @param unit the deployment unit * @param file the metadata file * @return the document * @throws Exception for any error */ protected Document doParse(VFSDeploymentUnit unit, VirtualFile file) throws Exception { if (file == null) throw new IllegalArgumentException("Null file"); log.debugf("Parsing: %1s", file.getName()); InputSource source = new VFSInputSource(file); DocumentBuilderFactory factory = getDocumentBuilderFactory(); DocumentBuilder parser = factory.newDocumentBuilder(); parser.setEntityResolver(new JBossEntityResolver()); return parser.parse(source); }
@Override protected T parse(VFSDeploymentUnit unit, VirtualFile file, T root) throws Exception { InputSource source = new VFSInputSource(file); return getHelper().parse(source, root, getObjectModelFactory(root)); }