Tabnine Logo
Resource
Code IndexAdd Tabnine to your IDE (free)

How to use
Resource
in
com.google.gwt.dev.resource

Best Java code snippets using com.google.gwt.dev.resource.Resource (Showing top 20 results out of 315)

origin: com.vaadin.external.gwt/gwt-user

@Override
public InputSource resolveEntity(String publicId, String systemId) {
 String matchingPrefix = findMatchingPrefix(systemId);
 Resource resource = null;
 if (matchingPrefix != null) {
  resource =
    resourceOracle.getResource(RESOURCES + systemId.substring(matchingPrefix.length()));
 }
 if (resource == null) {
  resource = resourceOracle.getResource(pathBase + systemId);
 }
 if (resource != null) {
  String content;
  try {
   InputStream resourceStream = resource.openContents();
   content = Util.readStreamAsString(resourceStream);
  } catch (IOException ex) {
   logger.log(TreeLogger.ERROR, "Error reading resource: " + resource.getLocation());
   throw new RuntimeException(ex);
  }
  InputSource inputSource = new InputSource(new StringReader(content));
  inputSource.setPublicId(publicId);
  inputSource.setSystemId(resource.getPath());
  return inputSource;
 }
 /*
  * Let Sax find it on the interweb.
  */
 return null;
}
origin: seanchenxi/gwt-storage

private StorageSerialization parseXmlResource(Resource resource) throws UnableToCompleteException {
 InputStream input = null;
 try{
  JAXBContext jaxbContext = JAXBContext.newInstance(StorageSerialization.class);
  Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
  Source source = createSAXSource(input = resource.openContents());
  StorageSerialization storageSerialization = (StorageSerialization)unmarshaller.unmarshal(source);
  storageSerialization.setPath(resource.getPath());
  return storageSerialization;
 }catch(Exception e){
  logger.branch(TreeLogger.Type.WARN, "Error while parsing xml resource at " + resource.getPath(), e);
  throw new UnableToCompleteException();
 } finally{
  try{
   if(input != null) input.close();
  }catch(Exception e){
   //To ignore
  }
 }
}
origin: playn/playn

private static String getContentType(TreeLogger logger, Resource resource) {
 String name = resource.getPath().toLowerCase();
 int pos = name.lastIndexOf('.');
 String extension = pos == -1 ? "" : name.substring(pos);
 String contentType = EXTENSION_MAP.get(extension);
 if (contentType == null) {
  logger.log(
    TreeLogger.WARN,
    "No Content Type mapping for files with '" + extension
      + "' extension. Please add a mapping to the "
      + AutoClientBundleGenerator.class.getCanonicalName() + " class.");
  contentType = "application/octet-stream";
 }
 return contentType;
}
origin: com.vaadin.external.gwt/gwt-user

InputStream resourceStream = null;
try {
 resourceStream = resource.openContents();
} catch (IOException ex) {
 logger.log(TreeLogger.ERROR, "Error opening resource: " + resource.getLocation());
 throw new RuntimeException(ex);
origin: net.wetheinter/gwt-user

binderPrintWriter.println("// .ui.xml template last modified: " + resource.getLastModified());
Document doc = getW3cDoc(logger, designTime, resourceOracle, templatePath, resource);
designTime.rememberPathForElements(doc);
origin: threerings/playn

private static String getContentType(TreeLogger logger, Resource resource) {
 String name = resource.getPath().toLowerCase();
 int pos = name.lastIndexOf('.');
 String extension = pos == -1 ? "" : name.substring(pos);
 String contentType = EXTENSION_MAP.get(extension);
 if (contentType == null) {
  logger.log(
    TreeLogger.WARN,
    "No Content Type mapping for files with '" + extension
      + "' extension. Please add a mapping to the "
      + AutoClientBundleGenerator.class.getCanonicalName() + " class.");
  contentType = "application/octet-stream";
 }
 return contentType;
}
origin: com.jhickman/gwt-customuibinder

private Document getW3cDoc(MortalLogger logger, DesignTimeUtils designTime,
  ResourceOracle resourceOracle, String templatePath)
  throws UnableToCompleteException {
 Resource resource = resourceOracle.getResourceMap().get(templatePath);
 if (null == resource) {
  logger.die("Unable to find resource: " + templatePath);
 }
 Document doc = null;
 try {
  String content = designTime.getTemplateContent(templatePath);
  if (content == null) {
   content = Util.readStreamAsString(resource.openContents());
  }
  doc = new W3cDomHelper(logger.getTreeLogger(), resourceOracle).documentFor(
    content, resource.getPath());
 } catch (SAXParseException e) {
  logger.die(
    "Error parsing XML (line " + e.getLineNumber() + "): "
      + e.getMessage(), e);
 }
 return doc;
}
origin: net.wetheinter/gwt-user

InputStream resourceStream = null;
try {
 resourceStream = resource.openContents();
} catch (IOException ex) {
 logger.log(TreeLogger.ERROR, "Error opening resource: " + resource.getLocation());
 throw new RuntimeException(ex);
origin: com.vaadin.external.gwt/gwt-user

binderPrintWriter.println("// .ui.xml template last modified: " + resource.getLastModified());
Document doc = getW3cDoc(logger, designTime, resourceOracle, templatePath, resource);
designTime.rememberPathForElements(doc);
origin: net.wetheinter/gwt-user

@Override
public InputSource resolveEntity(String publicId, String systemId) {
 String matchingPrefix = findMatchingPrefix(systemId);
 Resource resource = null;
 if (matchingPrefix != null) {
  resource =
    resourceOracle.getResource(RESOURCES + systemId.substring(matchingPrefix.length()));
 }
 if (resource == null) {
  resource = resourceOracle.getResource(pathBase + systemId);
 }
 if (resource != null) {
  String content;
  try {
   InputStream resourceStream = resource.openContents();
   content = Util.readStreamAsString(resourceStream);
  } catch (IOException ex) {
   logger.log(TreeLogger.ERROR, "Error reading resource: " + resource.getLocation());
   throw new RuntimeException(ex);
  }
  InputSource inputSource = new InputSource(new StringReader(content));
  inputSource.setPublicId(publicId);
  inputSource.setSystemId(resource.getPath());
  return inputSource;
 }
 /*
  * Let Sax find it on the interweb.
  */
 return null;
}
origin: io.playn/playn-html

private static String getContentType(TreeLogger logger, Resource resource) {
 String name = resource.getPath().toLowerCase();
 int pos = name.lastIndexOf('.');
 String extension = pos == -1 ? "" : name.substring(pos);
 String contentType = EXTENSION_MAP.get(extension);
 if (contentType == null) {
  logger.log(
    TreeLogger.WARN,
    "No Content Type mapping for files with '" + extension
      + "' extension. Please add a mapping to the "
      + AutoClientBundleGenerator.class.getCanonicalName() + " class.");
  contentType = "application/octet-stream";
 }
 return contentType;
}
origin: com.vaadin.external.gwt/gwt-user

private Document getW3cDoc(MortalLogger logger, DesignTimeUtils designTime,
  ResourceOracle resourceOracle, String templatePath, Resource resource)
  throws UnableToCompleteException {
 Document doc = null;
 try {
  String content = designTime.getTemplateContent(templatePath);
  if (content == null) {
   content = Util.readStreamAsString(resource.openContents());
  }
  doc = new W3cDomHelper(logger.getTreeLogger(), resourceOracle).documentFor(
    content, resource.getPath());
 } catch (IOException iex) {
  logger.die("Error opening resource:" + resource.getLocation(), iex);
 } catch (SAXParseException e) {
  logger.die(
    "Error parsing XML (line " + e.getLineNumber() + "): "
      + e.getMessage(), e);
 }
 return doc;
}
origin: io.playn/playn-html

/**
 * Filter file set, preferring *.mp3 files where alternatives exist.
 */
private HashSet<Resource> preferMp3(HashSet<Resource> files) {
 HashMap<String, Resource> map = new HashMap<String, Resource>();
 for (Resource file : files) {
  String path = stripExtension(file.getPath());
  if (file.getPath().endsWith(".mp3") || !map.containsKey(path)) {
   map.put(path, file);
  }
 }
 return new HashSet<Resource>(map.values());
}
origin: net.wetheinter/gwt-user

private Document getW3cDoc(MortalLogger logger, DesignTimeUtils designTime,
  ResourceOracle resourceOracle, String templatePath, Resource resource)
  throws UnableToCompleteException {
 Document doc = null;
 try {
  String content = designTime.getTemplateContent(templatePath);
  if (content == null) {
   content = Util.readStreamAsString(resource.openContents());
  }
  doc = new W3cDomHelper(logger.getTreeLogger(), resourceOracle).documentFor(
    content, resource.getPath());
 } catch (IOException iex) {
  logger.die("Error opening resource:" + resource.getLocation(), iex);
 } catch (SAXParseException e) {
  logger.die(
    "Error parsing XML (line " + e.getLineNumber() + "): "
      + e.getMessage(), e);
 }
 return doc;
}
origin: threerings/playn

/**
 * Filter file set, preferring *.mp3 files where alternatives exist.
 */
private HashSet<Resource> preferMp3(HashSet<Resource> files) {
 HashMap<String, Resource> map = new HashMap<String, Resource>();
 for (Resource file : files) {
  String path = stripExtension(file.getPath());
  if (file.getPath().endsWith(".mp3") || !map.containsKey(path)) {
   map.put(path, file);
  }
 }
 return new HashSet<Resource>(map.values());
}
origin: playn/playn

/**
 * Filter file set, preferring *.mp3 files where alternatives exist.
 */
private HashSet<Resource> preferMp3(HashSet<Resource> files) {
 HashMap<String, Resource> map = new HashMap<String, Resource>();
 for (Resource file : files) {
  String path = stripExtension(file.getPath());
  if (file.getPath().endsWith(".mp3") || !map.containsKey(path)) {
   map.put(path, file);
  }
 }
 return new HashSet<Resource>(map.values());
}
origin: fr.putnami.pwt/pwt

private Resource getTemplateResource(GeneratorContext context) {
  String packageResourcePath = this.targetType.getPackage().getName().replace('.', '/') + "/";
  ResourceOracle resourceOracle = context.getResourcesOracle();
  Map<String, Resource> reourceMap = new HashMap<>();
  for (Resource resource : resourceOracle.getResources()) {
    reourceMap.put(resource.getPath(), resource);
  }
  String templatePath =
    packageResourcePath + this.templateName + "_" + this.locale + UiBinderLocalizedCreator.TEMPLATE_SUFFIX;
  Resource templateResource = reourceMap.get(templatePath);
  if (templateResource == null) {
    this.locale = null;
    templatePath = packageResourcePath + this.templateName + UiBinderLocalizedCreator.TEMPLATE_SUFFIX;
    templateResource = reourceMap.get(templatePath);
  }
  if (templateResource != null) {
    this.templateName = templatePath.replace(packageResourcePath, "");
  }
  return templateResource;
}
origin: Putnami/putnami-web-toolkit

private Resource getTemplateResource(GeneratorContext context) {
  String packageResourcePath = this.targetType.getPackage().getName().replace('.', '/') + "/";
  ResourceOracle resourceOracle = context.getResourcesOracle();
  Map<String, Resource> reourceMap = new HashMap<>();
  for (Resource resource : resourceOracle.getResources()) {
    reourceMap.put(resource.getPath(), resource);
  }
  String templatePath =
    packageResourcePath + this.templateName + "_" + this.locale + UiBinderLocalizedCreator.TEMPLATE_SUFFIX;
  Resource templateResource = reourceMap.get(templatePath);
  if (templateResource == null) {
    this.locale = null;
    templatePath = packageResourcePath + this.templateName + UiBinderLocalizedCreator.TEMPLATE_SUFFIX;
    templateResource = reourceMap.get(templatePath);
  }
  if (templateResource != null) {
    this.templateName = templatePath.replace(packageResourcePath, "");
  }
  return templateResource;
}
origin: io.playn/playn-html

String relativePath = resource.getPath();
String filename = resource.getPath().substring(resource.getPath().lastIndexOf('/') + 1);
String contentType = getContentType(logger, resource);
String methodName = stripExtension(filename);
origin: playn/playn

String relativePath = resource.getPath();
String filename = resource.getPath().substring(resource.getPath().lastIndexOf('/') + 1);
String contentType = getContentType(logger, resource);
String methodName = stripExtension(filename);
com.google.gwt.dev.resourceResource

Most used methods

  • getPath
  • openContents
  • getLastModified
  • getLocation

Popular in Java

  • Reading from database using SQL prepared statement
  • getSharedPreferences (Context)
  • getSystemService (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now