This method calls the PMML compiler to get PMMLResource objects which are used to
create one or more PackageDescr objects
@param resource
@return
@throws DroolsParserException
@throws IOException
7097
private List<PackageDescr> getPackageDescrs(Resource resource) throws DroolsParserException, IOException {
        List<PMMLResource> resources = pmmlCompiler.precompile(resource.getInputStream(), null, null);
        if (resources != null && !resources.isEmpty()) {
            return generatedResourcesToPackageDescr(resource, resources);
        }
        return null;
    }
504318
public static Reader getResourceAsReader(String resource) {
        InputStream in = classLoaderWrapper.getResourceAsStream(resource);
        if (in == null) {
            return null;
        }
        return new InputStreamReader(in);
    }
686376
public void addPackageFromXml(final Reader reader) throws DroolsParserException,
            IOException {
        this.resource = new ReaderResource(reader, ResourceType.XDRL);
        final XmlPackageReader xmlReader = new XmlPackageReader(this.configuration.getSemanticModules());
        xmlReader.getParser().setClassLoader(this.rootClassLoader);

        try {
            xmlReader.read(reader);
        } catch (final SAXException e) {
            throw new DroolsParserException(e.toString(),
                                            e.getCause());
        }

        addPackage(xmlReader.getPackageDescr());
        this.resource = null;
    }
125487
public Resource parse(XmlPullParser xpp)  throws IOException, FHIRFormatError, XmlPullParserException {
		if (xpp.getNamespace() == null)
			throw new FHIRFormatError("This does not appear to be a FHIR resource (no namespace '"+xpp.getNamespace()+"') (@ /) "+Integer.toString(xpp.getEventType()));
		if (!xpp.getNamespace().equals(FHIR_NS))
			throw new FHIRFormatError("This does not appear to be a FHIR resource (wrong namespace '"+xpp.getNamespace()+"') (@ /)");
		return parseResource(xpp);
	}
641835
public void createDocumentClassificationFactory(
      final TrainingParameters params) throws IOException {
    final String featureDescription = DocumentFeatureDescriptor
        .createDocumentFeatureDescriptor(params);
    System.err.println(featureDescription);
    final byte[] featureGeneratorBytes = featureDescription
        .getBytes(Charset.forName("UTF-8"));
    final Map<String, Object> resources = DocumentModelResources
        .loadDocumentResources(params);
    //TODO add default feature generator
    setDocumentClassifierFactory(
        DocumentClassifierFactory.create(DocumentClassifierFactory.class.getName(),
            featureGeneratorBytes, resources));
  }
909054
public static InputStream getResourceAsStream(String resource) throws IOException {
    InputStream in = null;
    ClassLoader loader = ResourcesUtils.class.getClassLoader();
    if (loader != null) {
      in = loader.getResourceAsStream(resource);
    }
    if (in == null) {
      in = ClassLoader.getSystemResourceAsStream(resource);
    }
    if (in == null) {
      throw new IOException("Could not find resource " + resource);
    }
    return in;
  }
701512
public Resource write(@NonNull Resource resource) throws IOException {
      Resource stringResource = new StringResource();
      try (PrintStream printStream = new PrintStream(stringResource.outputStream())) {
         print(printStream);
      }
      resource.write(stringResource.readToString());
      return resource;
   }
743288
public List<CmsVariationBean> getVariations(String resource) {

        List<String> ret = (List<String>)(m_filePaths.get(resource));
        List<CmsVariationBean> res = new ArrayList<CmsVariationBean>();
        if (ret == null) {
            return new ArrayList<CmsVariationBean>();
        }
        for (String r : ret) {
            res.add(new CmsVariationBean(r));
        }
        return res;
    }
699215
public static Node getJcrNode(final FedoraResource resource) {
        if (resource instanceof FedoraResourceImpl) {
            return ((FedoraResourceImpl)resource).getNode();
        }
        throw new IllegalArgumentException("FedoraResource is of the wrong type");
    }
1147936
public static IProject getProject(Resource resource) {
		ProjectAdapter adapter = (ProjectAdapter) EcoreUtil.getAdapter(resource.getResourceSet().eAdapters(), ProjectAdapter.class);
		if (adapter == null) {
			final String platformString = resource.getURI().toPlatformString(true);
			final IProject project = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(platformString)).getProject();
			adapter = new ProjectAdapter(project);
			resource.getResourceSet().eAdapters().add(adapter);
		}
		return adapter.getProject();
	}
672703
public static EnumerationIter<URL> getResourceIter(String resource) {
		final Enumeration<URL> resources;
		try {
			resources = ClassLoaderUtil.getClassLoader().getResources(resource);
		} catch (IOException e) {
			throw new IORuntimeException(e);
		}
		return new EnumerationIter<>(resources);
	}
370669
private void writeResources() throws IOException
   {
      writeAttributeTypes("resource_types", ResourceField.values());

      m_writer.writeStartList("resources");
      for (Resource resource : m_projectFile.getResources())
      {
         writeFields(null, resource, ResourceField.values());
      }
      m_writer.writeEndList();
   }
846928
public List<ReconfigBeanDefinitionHolder> load(Resource resource) {
    List<ReconfigBeanDefinitionHolder> holders = new ArrayList<ReconfigBeanDefinitionHolder>();
    try {
      InputStream inputStream = resource.getInputStream();
      try {
        InputSource inputSource = new InputSource(inputStream);
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = factory.newDocumentBuilder();
        Document doc = docBuilder.parse(inputSource);
        Element root = doc.getDocumentElement();
        NodeList nl = root.getChildNodes();
        BeanDefinitionParser parser = new BeanDefinitionParser();
        for (int i = 0; i < nl.getLength(); i++) {
          Node node = nl.item(i);
          if (node instanceof Element) {
            Element ele = (Element) node;
            ReconfigBeanDefinitionHolder holder = parser.parseBeanDefinitionElement(ele);
            holders.add(holder);
          }
        }
      } finally {
        if (null != inputStream) {
          inputStream.close();
        }
      }
    } catch (Exception ex) {
      throw new RuntimeException("IOException parsing XML document from " + resource.getDescription(), ex);
    }
    return holders;
  }
40129
@Pure
	protected String formatResource(XtextResource resource) {
		assert resource != null;
		try {
			final ITextRegionAccess regionAccess = this.regionAccessBuilder.get().forNodeModel(resource).create();
			final FormatterRequest formatterRequest = new FormatterRequest();
			formatterRequest.setAllowIdentityEdits(false);
			formatterRequest.setTextRegionAccess(regionAccess);
			final IPreferenceValues preferenceValues = FormatterFacade.this.configurationProvider
					.getPreferenceValues(resource);
			formatterRequest.setPreferences(TypedPreferenceValues.castOrWrap(preferenceValues));
			final List<ITextReplacement> replacements = this.formatter.format(formatterRequest);
			return regionAccess.getRewriter().renderToString(replacements);
		} catch (Exception exception) {
			throw Exceptions.sneakyThrow(exception);
		}
	}
635366
public static boolean isXmlContent(CmsResource resource) {

        boolean result = false;
        if (resource != null) {
            // avoid array index out of bound exception:
            if (!resource.isFolder()) {
                result = OpenCms.getResourceManager().getResourceType(resource) instanceof CmsResourceTypeXmlContent;
            }
        }
        return result;
    }
689619
public ResourceMetaData getResourceMetaData(Resource resource)
    {
        Object o=resource.getAssociate();
        if (o instanceof ResourceMetaData)
            return (ResourceMetaData)o;
        return new ResourceMetaData(resource);
    }
960839
public static InputStream loadResource(final String resource) throws FileNotFoundException {
        final boolean hasLeadingSlash = resource.startsWith("/");
        final String stripped = hasLeadingSlash ? resource.substring(1) : resource;

        InputStream stream = null;

        final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        if (classLoader != null) {
            stream = classLoader.getResourceAsStream(resource);
            if (stream == null && hasLeadingSlash) {
                stream = classLoader.getResourceAsStream(stripped);
            }
        }

        if (stream == null) {
            throw new FileNotFoundException("resource " + resource + " not found");
        }

        return stream;
    }