List of usage examples for com.google.common.io Resources getResource
public static URL getResource(Class<?> contextClass, String resourceName)
From source file:services.docx.MemoServiceDocx.java
@PostConstruct public void init() throws IOException, LoadTemplateException { final byte[] bytes = Resources.toByteArray(Resources.getResource(this.getClass(), "memo.docx")); wordprocessingMLPackage = docxService.loadPackage(new ByteArrayInputStream(bytes)); }
From source file:org.isisaddons.module.docx.dom.IoHelper.java
public URL asUrl(final String fileName) { return Resources.getResource(baseClass, fileName); }
From source file:br.com.objectos.way.core.code.jdt.AstReaderResource.java
@Override void setSource(ASTParser parser) throws Exception { String name = resourceName.substring(resourceName.lastIndexOf('/')); parser.setUnitName(name);// www . java 2 s . c o m URL url = Resources.getResource(getClass(), resourceName); Reader reader = Resources.asCharSource(url, Charsets.UTF_8).openStream(); String source = CharStreams.toString(reader); char[] chars = source.toCharArray(); parser.setSource(chars); }
From source file:services.docx.DisposicionServiceDocx.java
@PostConstruct public void init() throws IOException, LoadTemplateException { final byte[] bytes = Resources.toByteArray(Resources.getResource(this.getClass(), "disposicion.docx")); wordprocessingMLPackage = docxService.loadPackage(new ByteArrayInputStream(bytes)); }
From source file:services.docx.ResolucionServiceDocx.java
@PostConstruct public void init() throws IOException, LoadTemplateException { final byte[] bytes = Resources.toByteArray(Resources.getResource(this.getClass(), "resolucion.docx")); wordprocessingMLPackage = docxService.loadPackage(new ByteArrayInputStream(bytes)); }
From source file:services.docx.ExpedienteServiceDocx.java
@PostConstruct public void init() throws IOException, LoadTemplateException { final byte[] bytes = Resources.toByteArray(Resources.getResource(this.getClass(), "expediente.docx")); wordprocessingMLPackage = docxService.loadPackage(new ByteArrayInputStream(bytes)); }
From source file:org.incode.eurocommercial.contactapp.fixture.scenarios.demo.DemoFixture.java
@Override protected void execute(final ExecutionContext ec) { // zap everything ec.executeChild(this, new ContactRoleTearDown()); ec.executeChild(this, new ContactNumberTearDown()); ec.executeChild(this, new ContactTearDown()); ec.executeChild(this, new ContactGroupTearDown()); ec.executeChild(this, new CountryTearDown()); // load data from spreadsheet final URL spreadsheet = Resources.getResource(DemoFixture.class, getSpreadsheetBasename() + ".xlsx"); final ExcelFixture fs = new ExcelFixture(spreadsheet, getHandlers()); ec.executeChild(this, fs); // make objects created by ExcelFixture available to our caller. final Map<Class, List<Object>> objectsByClass = fs.getObjectsByClass(); getContacts().addAll(FluentIterable.from((List) objectsByClass.get(ContactImport.class)) .filter(Predicates.notNull()).toList()); }
From source file:com.nesscomputing.migratory.mojo.database.util.TemplatingStatementLocator.java
@Override public String locate(final String statementName, final StatementContext context) throws Exception { if (StringUtils.isEmpty(statementName)) { throw new IllegalStateException("Statement Name can not be empty/null!"); }// w ww . j av a 2s .c om if (statementName.charAt(0) == '#') { // Multiple templates can be in a string template group. In that case, the name is #<template-group:<statement name> final String[] statementNames = StringUtils.split(statementName.substring(1), ":"); final String location = prefix + statementNames[0] + ".st"; LOG.trace("Loading SQL: %s", location); final URL locationUrl = Resources.getResource(this.getClass(), location); if (locationUrl == null) { throw new IllegalArgumentException("Location '" + location + "' does not exist!"); } final String contents = loaderManager.loadFile(locationUrl.toURI()); if (statementNames.length == 1) { final StringTemplate template = new StringTemplate(contents, AngleBracketTemplateLexer.class); template.setAttributes(context.getAttributes()); final String sql = template.toString(); LOG.trace("SQL: %s", sql); return sql; } else { final StringTemplateGroup group = new StringTemplateGroup(new StringReader(contents), AngleBracketTemplateLexer.class); LOG.trace("Found %s in %s", group.getTemplateNames(), locationUrl); final StringTemplate template = group.getInstanceOf(statementNames[1]); template.setAttributes(context.getAttributes()); final String sql = template.toString(); LOG.trace("SQL: %s", sql); return sql; } } else { return statementName; } }
From source file:org.sonar.server.issue.ws.AuthorsAction.java
@Override public void define(WebService.NewController controller) { NewAction action = controller.createAction(ACTION_AUTHORS).setSince("5.1") .setDescription("Search SCM accounts which match a given query") .setResponseExample(Resources.getResource(this.getClass(), "authors-example.json")) .setHandler(this); action.createParam(Param.TEXT_QUERY).setDescription("A pattern to match SCM accounts against") .setExampleValue("luke"); action.createParam(Param.PAGE_SIZE).setDescription("The size of the list to return").setExampleValue("25") .setDefaultValue("10"); }
From source file:org.isisaddons.module.excel.fixture.scripts.CreateAllToDoItems.java
private List<ExcelModuleDemoToDoItem> load(final ExecutionContext executionContext, final String resourceName) { final URL excelResource = Resources.getResource(getClass(), resourceName); final ExcelFixture excelFixture = new ExcelFixture(excelResource, ExcelModuleDemoToDoItemRowHandler.class); excelFixture.setExcelResourceName(resourceName); executionContext.executeChild(this, excelFixture); return (List<ExcelModuleDemoToDoItem>) excelFixture.getObjects(); }