List of usage examples for java.lang Package toString
@Override
public String toString()
From source file:Main.java
public static void main(String[] args) { // get the java lang package Package pack = Package.getPackage("java.lang"); // print the package as a string System.out.println("" + pack.toString()); }
From source file:edu.american.student.stonewall.util.Deployer.java
private static String getPath(Class<? extends Page> p) { Package pkg = p.getPackage(); System.out.println(pkg.toString()); return pkg.toString().replace("root", "").replace(".", File.separator).replace("package", "").trim(); }
From source file:ome.util.ReflectionUtils.java
public static Method[] getGettersAndSetters(Object obj) { Method[] methods, superMethods = null; methods = obj.getClass().getDeclaredMethods(); Package pkg = obj.getClass().getPackage(); if (null != pkg && pkg.toString().indexOf("ome.model2") > -1) {// FIXME // not // valid superMethods = obj.getClass().getSuperclass().getDeclaredMethods(); }//from www . jav a2 s. c o m List goodMethods = checkGettersAndSetters(methods); goodMethods.addAll(checkGettersAndSetters(superMethods)); return (Method[]) goodMethods.toArray(new Method[goodMethods.size()]); }
From source file:org.dataconservancy.ui.it.FileHttpAPIIT.java
@Before public void setUp() throws Exception { adminUserLogin = reqFactory.createLoginRequest(adminUser).asHttpPost(); defaultUserLogin = reqFactory.createLoginRequest(defaultUser).asHttpPost(); approvedUserLogin = reqFactory.createLoginRequest(approvedUser).asHttpPost(); logout = reqFactory.createLogoutRequest().asHttpGet(); if (!areObjectsSeeded) { log.trace("Seeding objects ..."); HttpAssert.assertStatus(httpClient, adminUserLogin, 300, 399, "Unable to login as admin user!"); // A generic project with adminUser as a PI project = new Project(); project.setName("FileHttpAPIIT Test Project"); project.setDescription("Test Project For TestHttpAPIIT"); project.addNumber("123456"); project.setFundingEntity("Cash"); project.setStartDate(new DateTime(2012, 6, 13, 0, 0)); project.setEndDate(new DateTime(2013, 6, 13, 0, 0)); project.addPi(adminUser.getId()); project = reqFactory.createProjectApiAddRequest(project).execute(httpClient); log.trace("Seeded Project, id {}", project.getId()); log.trace(project.toString());//from w ww . ja va2 s . co m // A generic collection with approvedUser as a depositor collection = new Collection(); collection.setTitle("FileHttpAPIIT Test Collection"); collection.setSummary("Test Collection for TestHttpAPIIT"); collection.setId(reqFactory.createIdApiRequest(COLLECTION).execute(httpClient)); List<PersonName> creators = new ArrayList<PersonName>(); creators.add(new PersonName("Mr.", "John", "Jack", "Doe", "II")); collection.setCreators(creators); httpClient.execute(reqFactory.createCollectionRequest(collection, project).asHttpPost()).getEntity() .getContent().close(); HttpAssert.assertStatus(httpClient, new HttpGet(urlConfig.getViewCollectionUrl(collection.getId()).toURI()), 200, "Unable to create collection " + collection); log.trace("Seeded Collection, id {}", collection.getId()); log.trace(collection.toString()); httpClient.execute( reqFactory.createSetNewDepositorRequest(approvedUser.getId(), collection.getId()).asHttpPost()) .getEntity().getContent().close(); log.trace("Added depositor {} to Collection {}", approvedUser.getId(), collection.getId()); java.io.File tempFile = new java.io.File(FileHttpAPIIT.class.getResource(LINUX_FILE_ZIP_PATH).toURI()); dataFileContents = IOUtils.toByteArray(new FileInputStream(tempFile)); dataFileLengh = tempFile.length(); dataFile = new DataFile(null, tempFile.getName(), tempFile.toURI().toURL().toExternalForm(), URLConnection.getFileNameMap().getContentTypeFor(tempFile.getName()), tempFile.getPath(), tempFile.length(), new ArrayList<String>()); // A list of data files List<DataFile> dataFileList = new ArrayList<DataFile>(); dataFileList.add(dataFile); // A dataset to contain the data file dataSetDateTime = DateTime.now(); dataItem = new DataItem("FileHttpAPIIT Test DataItem", "Test DataItem for TestHttpAPIIT", reqFactory.createIdApiRequest(DATA_SET).execute(httpClient), approvedUser.getId(), dataSetDateTime, dataFileList, new ArrayList<String>(), collection.getId()); dataItem.setParentId(collection.getId()); dataFile.setParentId(dataItem.getId()); log.trace("Created DataItem with name {} and id {}", dataItem.getName(), dataItem.getId()); log.trace(dataItem.toString()); log.trace("DataItem ({}, {}) files:", dataItem.getName(), dataItem.getId()); for (DataFile f : dataItem.getFiles()) { log.trace("File id {}, name {}", f.getId(), f.getName()); } org.dataconservancy.ui.model.Package thePackage = new org.dataconservancy.ui.model.Package(); updatePackageId = reqFactory.createIdApiRequest(PACKAGE).execute(httpClient); thePackage.setId(updatePackageId); log.trace("Created Package, id {}", thePackage.getId()); log.trace(thePackage.toString()); httpClient.execute(reqFactory .createSingleFileDataItemDepositRequest(thePackage, dataItem, collection.getId(), tempFile) .asHttpPost()).getEntity().getContent().close(); // The Following construct seems suspicious. I am able to pull the // dataset from the archive via pollAndQueryArchiveForDataset, but // still end up making multiple calls to the getDepositStatusUrl // before I get back a deposited response. // I am, however, going to leave it be for now. dataItem = archiveSupport.pollAndQueryArchiveForDataItem(dataItem.getId()); String content; tryCount = 0; do { HttpResponse response = httpClient .execute(new HttpGet(urlConfig.getDepositStatusUrl(thePackage.getId()).toURI())); content = IOUtils.toString(response.getEntity().getContent()); Thread.sleep(1000L); } while (!content.contains("DEPOSITED") && tryCount++ < maxTries); log.trace("Seeded Package {} and DataItem {}, {}", new Object[] { thePackage.getId(), dataItem.getId(), dataItem.getName() }); log.trace(dataItem.toString()); for (DataFile f : dataItem.getFiles()) { log.trace(f.toString()); } // This is the datafile/dataset used in the deprecated file scenario java.io.File tempFileToUpdate = java.io.File.createTempFile("FileToUpdateHttpAPIIT", ".txt"); tempFileToUpdate.deleteOnExit(); PrintWriter updatedOut = new PrintWriter(tempFileToUpdate); dataFileToUpdateContents = "Can haz data? Again."; updatedOut.print(dataFileToUpdateContents); updatedOut.close(); dataFileToUpdate = new DataFile(null, tempFileToUpdate.getName(), tempFileToUpdate.toURI().toURL().toExternalForm(), URLConnection.getFileNameMap().getContentTypeFor(tempFileToUpdate.getName()), tempFileToUpdate.getPath(), tempFileToUpdate.getTotalSpace(), new ArrayList<String>()); // A list of data files List<DataFile> dataFileListToUpdate = new ArrayList<DataFile>(); dataFileListToUpdate.add(dataFileToUpdate); // A dataset to contain the data file dataSetDateTime = DateTime.now(); dataSetToUpdate = new DataItem("FileToUpdateHttpAPIIT Test DataItem", "Test DataItem to update for TestHttpAPIIT", reqFactory.createIdApiRequest(DATA_SET).execute(httpClient), approvedUser.getId(), dataSetDateTime, dataFileListToUpdate, new ArrayList<String>(), collection.getId()); dataSetToUpdate.setParentId(collection.getId()); dataFileToUpdate.setParentId(dataSetToUpdate.getId()); log.trace("Created DataItem with name {} and id {}", dataSetToUpdate.getName(), dataSetToUpdate.getId()); log.trace(dataSetToUpdate.toString()); log.trace("DataItem ({}, {}) files:", dataSetToUpdate.getName(), dataSetToUpdate.getId()); for (DataFile f : dataSetToUpdate.getFiles()) { log.trace("File id {}, name {}", f.getId(), f.getName()); } org.dataconservancy.ui.model.Package packageToUpdate = new org.dataconservancy.ui.model.Package(); packageToUpdate.setId(reqFactory.createIdApiRequest(PACKAGE).execute(httpClient)); httpClient.execute(reqFactory.createSingleFileDataItemDepositRequest(packageToUpdate, dataSetToUpdate, collection.getId(), tempFileToUpdate).asHttpPost()).getEntity().getContent().close(); dataSetToUpdate = archiveSupport.pollAndQueryArchiveForDataItem(dataSetToUpdate.getId()); tryCount = 0; do { HttpResponse response = httpClient .execute(new HttpGet(urlConfig.getDepositStatusUrl(packageToUpdate.getId()).toURI())); content = IOUtils.toString(response.getEntity().getContent()); Thread.sleep(1000L); } while (!content.contains("DEPOSITED") && tryCount++ < maxTries); log.trace("Seeded Package {} and DataItem {}, {}", new Object[] { thePackage.getId(), dataSetToUpdate.getId(), dataSetToUpdate.getName() }); log.trace(dataSetToUpdate.toString()); for (DataFile f : dataSetToUpdate.getFiles()) { log.trace(f.toString()); } httpClient.execute(logout).getEntity().getContent().close(); areObjectsSeeded = true; } }
From source file:uk.co.modularaudio.util.hibernate.ReflectionUtils.java
public static String getClassPackageAsPath(final Object o) { final Class<?> theObject = o.getClass(); final Package thePackage = theObject.getPackage(); final String packageAsString = thePackage.toString(); final String tmpVal = packageAsString.replaceAll("package\\s", ""); final String retVal = tmpVal.replaceAll("\\.", "/"); return retVal; }