List of usage examples for com.google.common.io Resources getResource
public static URL getResource(Class<?> contextClass, String resourceName)
From source file:org.apache.directory.server.dhcp.AbstractDhcpTestCase.java
@Nonnull protected ByteBuffer getByteBufferFromFile(@Nonnull String file) throws IOException { URL resource = Resources.getResource(getClass(), file); byte[] data = Resources.toByteArray(resource); return ByteBuffer.wrap(data); }
From source file:org.sonar.server.source.ws.IndexAction.java
@Override public void define(WebService.NewController controller) { WebService.NewAction action = controller.createAction("index") .setDescription(//from w w w . j av a2 s . co m "Get source code as line number / text pairs. Require See Source Code permission on file") .setSince("5.0").setResponseExample(Resources.getResource(getClass(), "example-index.json")) .setInternal(true).setHandler(this); action.createParam("resource").setRequired(true).setDescription("File key") .setExampleValue("my_project:/src/foo/Bar.php"); action.createParam("from").setDefaultValue(1).setDescription("First line"); action.createParam("to") .setDescription("Last line (excluded). If not specified, all lines are returned until end of file"); }
From source file:org.sonar.server.source.ws.RawAction.java
@Override public void define(WebService.NewController controller) { WebService.NewAction action = controller.createAction("raw") .setDescription("Get source code as raw text. Require 'See Source Code' permission on file") .setSince("5.0").setResponseExample(Resources.getResource(getClass(), "example-raw.txt")) .setHandler(this); action.createParam("key").setRequired(true).setDescription("File key") .setExampleValue("my_project:src/foo/Bar.php"); }
From source file:org.sonar.server.test.ws.CoverageShowAction.java
void define(WebService.NewController controller) { WebService.NewAction action = controller.createAction("show") .setDescription("Get code coverage. Require Browse permission on file's project<br/>" + "Each element of the result array is composed of:" + "<ol>" + "<li>Line number</li>" + "<li>Is the line covered?</li>" + "<li>Number of tests covering this line</li>" + "<li>Number of branches</li>" + "<li>Number of branches covered</li>" + "</ol>") .setSince("4.4").setResponseExample(Resources.getResource(getClass(), "coverage-example-show.json")) .setHandler(this); action.createParam(KEY).setRequired(true).setDescription("File key") .setExampleValue("my_project:/src/foo/Bar.php"); action.createParam(FROM).setDescription("First line to return. Starts at 1").setExampleValue("10") .setDefaultValue("1"); action.createParam(TO).setDescription("Last line to return (inclusive)").setExampleValue("20"); action.createParam(TYPE)//from w w w . j a v a 2s.c o m .setDescription("Type of coverage info to return :" + "<ul>" + "<li>UT : Unit Tests</li>" + "<li>IT : Integration Tests</li>" + "<li>OVERALL : Unit and Integration Tests</li>" + "</ul>") .setPossibleValues(CoverageService.TYPE.values()).setDefaultValue(CoverageService.TYPE.UT.name()); }
From source file:net.minecraftforge.gradle.util.mcp.GLConstantFixer.java
public GLConstantFixer() throws IOException { String text = Resources.toString(Resources.getResource(GLConstantFixer.class, "gl.json"), Charset.defaultCharset()); json = JsonFactory.GSON.fromJson(text, new TypeToken<List<GLConstantGroup>>() { }.getType());//from www . ja va2s . co m }
From source file:org.sonar.server.rule.ws.TagsAction.java
@Override public void define(WebService.NewController controller) { NewAction action = controller.createAction("tags").setDescription("List rule tags").setSince("4.4") .setHandler(this).setResponseExample(Resources.getResource(getClass(), "example-tags.json")); action.createParam(Param.TEXT_QUERY).setDescription("A pattern to match tags against") .setExampleValue("misra"); action.createParam("ps").setDescription("The size of the list to return, 0 for all tags") .setExampleValue("25").setDefaultValue("0"); action.createParam(PARAM_ORGANIZATION).setDescription("Organization key").setRequired(false) .setInternal(true).setExampleValue("my-org").setSince("6.4"); }
From source file:org.sonar.server.source.ws.HashAction.java
@Override public void define(WebService.NewController controller) { WebService.NewAction action = controller.createAction("hash").setDescription( "Show line line hashes for a given file. Require See Source Code permission on file's project<br/>") .setSince("5.0").setInternal(true) .setResponseExample(Resources.getResource(getClass(), "example-hash.txt")).setHandler(this); action.createParam("key").setRequired(true).setDescription("File key") .setExampleValue(KEY_FILE_EXAMPLE_001); }
From source file:org.incodehq.amberg.vshcolab.webapp.DomainApplication.java
private static String readLines(final Class<?> contextClass, final String resourceName) { try {//from w w w . j av a2s . co m List<String> readLines = Resources.readLines(Resources.getResource(contextClass, resourceName), Charset.defaultCharset()); final String aboutText = Joiner.on("\n").join(readLines); return aboutText; } catch (IOException e) { return "This is the VSH Colab exploration of the workflow domain"; } }
From source file:domainapp.fixture.scenarios.spreadsheets.CreateUsingSpreadsheet.java
@Override protected void execute(final ExecutionContext ec) { // defaults/*from ww w . j av a 2 s. c om*/ final String resourceName = checkParam("resourceName", ec, String.class); // validate final URL resource = Resources.getResource(getClass(), resourceName); byte[] bytes; try { bytes = Resources.toByteArray(resource); } catch (IOException e) { throw new IllegalArgumentException("Could not read from resource: " + resourceName); } // execute final Blob blob = new Blob(resourceName, ExcelService.XSLX_MIME_TYPE, bytes); final List<T> objects = excelService.fromExcel(blob, cls); for (final T obj : objects) { doPersist(obj); this.objects.add(obj); } }
From source file:org.sonar.server.plugins.ws.InstalledPluginsWsAction.java
@Override public void define(WebService.NewController controller) { controller.createAction("installed").setDescription( "Get the list of all the plugins installed on the SonarQube instance, sorted by plugin name") .setSince("5.2").setHandler(this) .setResponseExample(Resources.getResource(this.getClass(), "example-installed_plugins.json")); }