com.google.gwt.dev.util.Util类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(223)

本文整理了Java中com.google.gwt.dev.util.Util类的一些代码示例,展示了Util类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util类的具体详情如下:
包路径:com.google.gwt.dev.util.Util
类名称:Util

Util介绍

暂无

代码示例

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. @Override
  2. public void prepare(TreeLogger logger, ResourceContext context,
  3. ClientBundleRequirements requirements, JMethod method)
  4. throws UnableToCompleteException {
  5. URL[] urls = ResourceGeneratorUtil.findResources(logger, context, method);
  6. if (urls.length != 1) {
  7. logger.log(TreeLogger.ERROR, "Exactly one resource must be specified",
  8. null);
  9. throw new UnableToCompleteException();
  10. }
  11. URL resource = urls[0];
  12. String toWrite = Util.readURLAsString(resource);
  13. // This de-duplicates strings in the bundle.
  14. if (!hashes.containsKey(toWrite)) {
  15. hashes.put(toWrite, currentIndex++);
  16. if (!first) {
  17. data.append(",\n");
  18. } else {
  19. first = false;
  20. }
  21. data.append('"');
  22. data.append(Generator.escape(toWrite));
  23. data.append('"');
  24. }
  25. // Store the (possibly n:1) mapping of resource function to bundle index.
  26. offsets.put(method.getName(), hashes.get(toWrite));
  27. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. private String getMd5HashOfData() {
  2. return Util.computeStrongName(Util.getBytes(data.toString()));
  3. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. public Void call() throws Exception {
  2. if (mode.isEmitClasses()) {
  3. String fileName = state.type.getInternalName();
  4. if (fileName == null) {
  5. System.err.println("Got null filename from " + state.type);
  6. return null;
  7. }
  8. fileName += ".class";
  9. emitter.emit(fileName, state.contents);
  10. }
  11. if (mode.isEmitSource()) {
  12. String sourcePath = getPackagePath(state.originalType) + state.source;
  13. String destPath = getPackagePath(state.type) + state.source;
  14. if (sources.add(sourcePath) && loader.exists(sourcePath)) {
  15. String contents = Util.readStreamAsString(loader.getResourceAsStream(sourcePath));
  16. emitter.emit(destPath, new ByteArrayInputStream(Util.getBytes(contents)));
  17. }
  18. }
  19. return null;
  20. }
  21. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. private static String key(ImageResourceDeclaration image, URL url) {
  2. return Util.computeStrongName(Util.readURLAsBytes(url)) + ":"
  3. + image.getScaleHeight() + ":" + image.getScaleWidth();
  4. }

代码示例来源:origin: net.wetheinter/gwt-user

  1. byte[] data = Util.readURLAsBytes(url);
  2. Utility.writeTemplateBinaryFile(file, data);
  3. } else {
  4. String data = Util.readURLAsString(url);
  5. Utility.writeTemplateFile(file, data, replacements);

代码示例来源:origin: net.wetheinter/gwt-user

  1. boolean forceExternal) throws UnableToCompleteException {
  2. String strongName = Util.computeStrongName(data);
  3. String toReturn = strongNameToExpressions.get(strongName);
  4. if (toReturn != null) {

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

  1. public static void main(String[] args) throws Exception {
  2. String filename = args[0];
  3. int line = Integer.valueOf(args[1]);
  4. int col = Integer.valueOf(args[2]);
  5. SourceMapping consumer = SourceMapConsumerFactory.parse(Util.readFileAsString(new File(filename)));
  6. System.out.println(consumer.getMappingForLine(line, col));
  7. }
  8. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. private String computeDefaultPrefix(ResourceContext context) {
  2. SortedSet<JClassType> gssResources = computeOperableTypes(context);
  3. Adler32 checksum = new Adler32();
  4. for (JClassType type : gssResources) {
  5. checksum.update(Util.getBytes(type.getQualifiedSourceName()));
  6. }
  7. int seed = Math.abs((int) checksum.getValue());
  8. return encode(seed) + "-";
  9. }

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

  1. @Override
  2. public InputSource resolveEntity(String publicId, String systemId) {
  3. String matchingPrefix = findMatchingPrefix(systemId);
  4. Resource resource = null;
  5. if (matchingPrefix != null) {
  6. resource =
  7. resourceOracle.getResource(RESOURCES + systemId.substring(matchingPrefix.length()));
  8. }
  9. if (resource == null) {
  10. resource = resourceOracle.getResource(pathBase + systemId);
  11. }
  12. if (resource != null) {
  13. String content;
  14. try {
  15. InputStream resourceStream = resource.openContents();
  16. content = Util.readStreamAsString(resourceStream);
  17. } catch (IOException ex) {
  18. logger.log(TreeLogger.ERROR, "Error reading resource: " + resource.getLocation());
  19. throw new RuntimeException(ex);
  20. }
  21. InputSource inputSource = new InputSource(new StringReader(content));
  22. inputSource.setPublicId(publicId);
  23. inputSource.setSystemId(resource.getPath());
  24. return inputSource;
  25. }
  26. /*
  27. * Let Sax find it on the interweb.
  28. */
  29. return null;
  30. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. /**
  2. * Re-encode an image as a PNG to strip random header data.
  3. */
  4. private URL reencodeToTempFile(TreeLogger logger, ImageRect rect)
  5. throws UnableToCompleteException {
  6. try {
  7. byte[] imageBytes = ImageBundleBuilder.toPng(logger, rect);
  8. if (imageBytes == null) {
  9. return null;
  10. }
  11. File file = File.createTempFile(ImageResourceGenerator.class.getSimpleName(), ".png");
  12. file.deleteOnExit();
  13. Util.writeBytesToFile(logger, file, imageBytes);
  14. return file.toURI().toURL();
  15. } catch (IOException ex) {
  16. logger.log(TreeLogger.ERROR, "Unable to write re-encoded PNG", ex);
  17. throw new UnableToCompleteException();
  18. }
  19. }

代码示例来源:origin: net.wetheinter/gwt-user

  1. public String deploy(URL resource, String mimeType, boolean forceExternal)
  2. throws UnableToCompleteException {
  3. String fileName = ResourceGeneratorUtil.baseName(resource);
  4. byte[] bytes = Util.readURLAsBytes(resource);
  5. try {
  6. String finalMimeType = (mimeType != null)
  7. ? mimeType : resource.openConnection().getContentType();
  8. return deploy(fileName, finalMimeType, bytes, forceExternal);
  9. } catch (IOException e) {
  10. getLogger().log(TreeLogger.ERROR,
  11. "Unable to determine mime type of resource", e);
  12. throw new UnableToCompleteException();
  13. }
  14. }

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

  1. byte[] data = Util.readURLAsBytes(url);
  2. Utility.writeTemplateBinaryFile(file, data);
  3. } else {
  4. String data = Util.readURLAsString(url);
  5. Utility.writeTemplateFile(file, data, replacements);

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

  1. boolean forceExternal) throws UnableToCompleteException {
  2. String strongName = Util.computeStrongName(data);
  3. String toReturn = strongNameToExpressions.get(strongName);
  4. if (toReturn != null) {

代码示例来源:origin: net.wetheinter/gwt-user

  1. public static void main(String[] args) throws Exception {
  2. String filename = args[0];
  3. int line = Integer.valueOf(args[1]);
  4. int col = Integer.valueOf(args[2]);
  5. SourceMapping consumer = SourceMapConsumerFactory.parse(Util.readFileAsString(new File(filename)));
  6. System.out.println(consumer.getMappingForLine(line, col));
  7. }
  8. }

代码示例来源:origin: net.wetheinter/gwt-user

  1. private static String key(ImageResourceDeclaration image, URL url) {
  2. return Util.computeStrongName(Util.readURLAsBytes(url)) + ":"
  3. + image.getScaleHeight() + ":" + image.getScaleWidth();
  4. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. checksum.update(Util.getBytes(type.getQualifiedSourceName()));

代码示例来源:origin: net.wetheinter/gwt-user

  1. @Override
  2. public InputSource resolveEntity(String publicId, String systemId) {
  3. String matchingPrefix = findMatchingPrefix(systemId);
  4. Resource resource = null;
  5. if (matchingPrefix != null) {
  6. resource =
  7. resourceOracle.getResource(RESOURCES + systemId.substring(matchingPrefix.length()));
  8. }
  9. if (resource == null) {
  10. resource = resourceOracle.getResource(pathBase + systemId);
  11. }
  12. if (resource != null) {
  13. String content;
  14. try {
  15. InputStream resourceStream = resource.openContents();
  16. content = Util.readStreamAsString(resourceStream);
  17. } catch (IOException ex) {
  18. logger.log(TreeLogger.ERROR, "Error reading resource: " + resource.getLocation());
  19. throw new RuntimeException(ex);
  20. }
  21. InputSource inputSource = new InputSource(new StringReader(content));
  22. inputSource.setPublicId(publicId);
  23. inputSource.setSystemId(resource.getPath());
  24. return inputSource;
  25. }
  26. /*
  27. * Let Sax find it on the interweb.
  28. */
  29. return null;
  30. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. /**
  2. * Re-encode an image as a PNG to strip random header data.
  3. */
  4. private static URL renderToTempPngFile(TreeLogger logger,
  5. ImageBundleBuilder builder, Arranger arranger)
  6. throws UnableToCompleteException {
  7. try {
  8. byte[] imageBytes = builder.render(logger, arranger);
  9. if (imageBytes == null) {
  10. return null;
  11. }
  12. File file = File.createTempFile(ImageResourceGenerator.class.getSimpleName(), ".png");
  13. file.deleteOnExit();
  14. Util.writeBytesToFile(logger, file, imageBytes);
  15. return file.toURI().toURL();
  16. } catch (IOException ex) {
  17. logger.log(TreeLogger.ERROR, "Unable to write re-encoded PNG", ex);
  18. throw new UnableToCompleteException();
  19. }
  20. }

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

  1. public String deploy(URL resource, String mimeType, boolean forceExternal)
  2. throws UnableToCompleteException {
  3. String fileName = ResourceGeneratorUtil.baseName(resource);
  4. byte[] bytes = Util.readURLAsBytes(resource);
  5. try {
  6. String finalMimeType = (mimeType != null)
  7. ? mimeType : resource.openConnection().getContentType();
  8. return deploy(fileName, finalMimeType, bytes, forceExternal);
  9. } catch (IOException e) {
  10. getLogger().log(TreeLogger.ERROR,
  11. "Unable to determine mime type of resource", e);
  12. throw new UnableToCompleteException();
  13. }
  14. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. sw.indent();
  2. String toWrite = Util.readURLAsString(resource);

相关文章