List of usage examples for java.util List toString
public String toString()
From source file:egovframework.rte.fdl.filehandling.FilehandlingServiceTest.java
/** * @throws Exception//from w w w . j a va2s . c o m */ @SuppressWarnings("unchecked") @Test public void testReadFile() throws Exception { if (!EgovFileUtil.isExistsFile(filename)) EgovFileUtil.writeFile(filename, text, "UTF-8"); assertEquals(EgovFileUtil.readFile(new File(filename), "UTF-8"), text); //log.debug(EgovFileUtil.readTextFile(filename, false)); List<String> lines = FileUtils.readLines(new File(filename), "UTF-8"); log.debug(lines.toString()); String string = lines.get(0); assertEquals(text, string); }
From source file:edu.harvard.iq.dataverse.datasetutility.FileUploadTestPage.java
private void checkRetrievalTest() { msgt("checkRetrievalTest"); if (dataset == null) { msg("Dataset is null!!!"); }/*from ww w . j a v a2 s . com*/ boolean prettyPrint = true; List<HashMap> hashList = datasetVersionService.getBasicDatasetVersionInfo(dataset); if (hashList == null) { msg("hashList is null!!!"); return; } msgt("hashed! : " + hashList.size()); msg(hashList.toString()); GsonBuilder builder; if (prettyPrint) { // Add pretty printing builder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().setPrettyPrinting(); } else { builder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation(); } Gson gson = builder.create(); // ---------------------------------- // serialize this object + add the id // ---------------------------------- JsonElement jsonObj = gson.toJsonTree(hashList); msgt("Really?"); msg(jsonObj.toString()); }
From source file:de.meisl.eisstockitems.ImportTest.java
public void importFromFile(String fileName, long categoryId) throws ParseException, IOException { List<String> readLines = FileUtils.readLines(new File(fileName), "UTF-8"); for (String line : readLines) { DateFormat format = new SimpleDateFormat("dd.MM.yyyy", Locale.GERMAN); String[] split = line.split(",", -1); String regNr = split[0];// w w w . j a v a2 s . co m String ifipartnerid = split[1]; String producerName = split[2]; Date registrationDate = format.parse(split[3]); Date prodCeasedDate = split[4].isEmpty() ? null : format.parse(split[4]); Date sellingProhibitedDate = split[5].isEmpty() ? null : format.parse(split[5]); Date expiredDate = split[6].isEmpty() ? null : format.parse(split[6]); Date sellingCeasedDate = split[7].isEmpty() ? null : format.parse(split[7]); String remark = split[8]; // 1 Eisstockkrper // 2 Eisstockkrper fr Schler // 3 Stiele // 4 Winterlaufsohlen // 5 Grundplatten // 6 Sommerlaufsohlen mit glatter Laufflche // 7 Sommerlaufsohle - rot - Negativprofil (sehr schnel... // 8 Sommerlaufsohlen mit Negativprofil // 9 Zwischenplatten // 10 Runddauben Category category = categoryRepository.findOne(categoryId); Producer producer; Item item; List<Producer> findByIfiPartnerId = producerRepository.findByIfiPartnerIdAndName(ifipartnerid, producerName); int partnerListSize = findByIfiPartnerId.size(); if (partnerListSize > 0) { if (partnerListSize > 1) { System.err.println("Many partners for IFI partner ID '" + ifipartnerid + "': " + findByIfiPartnerId.toString()); } producer = findByIfiPartnerId.get(0); log.info("Found Producer for ifiPartnerId '" + ifipartnerid + "': " + producer); } else { log.info("Did not find Producer for ifiPartnerId '" + ifipartnerid + "' and name '" + producerName + "'"); producer = new Producer(); producer.setIfiPartnerId(ifipartnerid); producer.setName(producerName); producer.setUpdated(new Date()); producer = producerRepository.save(producer); log.info("Created Producer for ifiPartnerId '" + ifipartnerid + "': " + producer); } List<Item> findByRegNumber = itemRepository.findByRegNumber(regNr); if (findByRegNumber.size() > 0) { if (findByRegNumber.size() > 1) { throw new RuntimeException("more than 1 item with regNr '" + regNr + "'"); } item = findByRegNumber.get(0); log.info("Found Item for RegNr '" + regNr + "': " + item); } else { item = new Item(); item.setCategory(category); item.setProducer(producer); item.setRegNumber(regNr); item.setRemark(remark); item.setRegistrationDate(registrationDate); item.setExpired(expiredDate); item.setProductionCeased(prodCeasedDate); item.setSellingCeased(sellingCeasedDate); item.setSellingProhibited(sellingProhibitedDate); item.setUpdated(new Date()); item = itemRepository.save(item); log.info("Created Item for RegNr '" + regNr + "': " + item); } } }
From source file:com.agiletec.plugins.jacms.apsadmin.content.helper.ContentActionHelper.java
/** * Controlla le referenziazioni di un contenuto. Verifica la referenziazione di un contenuto con altri contenuti o pagine nel caso * di operazioni di ripubblicazione di contenuti non del gruppo ad accesso libero. * L'operazione si rende necessaria per ovviare a casi nel cui il contenuto, di un particolare gruppo, sia stato * pubblicato precedentemente in una pagina o referenziato in un'altro contenuto grazie alla associazione di questo con * altri gruppi abilitati alla visualizzazione. Il controllo evidenzia quali devono essere i gruppi al quale il contenuto * deve essere necessariamente associato (ed il perch) per salvaguardare le precedenti relazioni. * @param content Il contenuto da analizzare. * @param action L'action da valorizzare con i messaggi di errore. * @throws ApsSystemException In caso di errore. */// w w w.j av a 2 s . co m @Override public void scanReferences(Content content, ActionSupport action) throws ApsSystemException { if (!Group.FREE_GROUP_NAME.equals(content.getMainGroup()) && !content.getGroups().contains(Group.FREE_GROUP_NAME)) { HttpServletRequest request = ServletActionContext.getRequest(); try { String[] defNames = ApsWebApplicationUtils.getWebApplicationContext(request) .getBeanNamesForType(ContentUtilizer.class); for (int i = 0; i < defNames.length; i++) { Object service = null; try { service = ApsWebApplicationUtils.getWebApplicationContext(request).getBean(defNames[i]); } catch (Throwable t) { _logger.error("error loading ReferencingObject ", t); service = null; } if (service != null) { ContentUtilizer contentUtilizer = (ContentUtilizer) service; List<Object> utilizers = contentUtilizer.getContentUtilizers(content.getId()); if (null == utilizers) { continue; } Lang lang = this.getLangManager().getDefaultLang(); for (int j = 0; j < utilizers.size(); j++) { Object object = utilizers.get(j); if (service instanceof IContentManager && object instanceof String) { //Content ID Content refContent = this.getContentManager().loadContent(object.toString(), true); if (!content.getMainGroup().equals(refContent.getMainGroup()) && !content.getGroups().contains(refContent.getMainGroup())) { String[] args = { this.getGroupManager().getGroup(refContent.getMainGroup()) .getDescription(), object.toString() + " '" + refContent.getDescription() + "'" }; action.addFieldError("mainGroup", action.getText("error.content.referencedContent.wrongGroups", args)); } } else if (object instanceof IPage) { //Content ID IPage page = (IPage) object; if (!CmsPageActionUtil.isContentPublishableOnPage(content, page)) { List<String> pageGroups = new ArrayList<String>(); pageGroups.add(page.getGroup()); if (null != page.getExtraGroups()) { pageGroups.addAll(page.getExtraGroups()); } String[] args = { pageGroups.toString(), page.getTitle(lang.getCode()) }; action.addFieldError("mainGroup", action.getText("error.content.referencedPage.wrongGroups", args)); } } } } } } catch (Throwable t) { throw new ApsSystemException("Error in hasReferencingObject method", t); } } }
From source file:de.iteratec.iteraplan.businesslogic.exchange.elasticmi.read.TestExcelFormatCompatibilityBankModel.java
private void failWithMessages() { List<String> messageStrings = Lists.transform(process.getImportProcessMessages().getMessages(), new Function<Message, String>() { public String apply(Message input) { return input.getMessage(); }/*from w w w . j a va 2 s. co m*/ }); Assert.fail(messageStrings.toString()); }
From source file:com.redsqirl.dynamictable.SelectableTable.java
/** * Return the index of the all the selected rows, sorted by index * /*from w ww . java 2 s . co m*/ * @return */ public List<Integer> getAllSelected() { List<Integer> list = new LinkedList<Integer>(); for (int i = 0; i < getRows().size(); i++) { SelectableRow selectableRow = getRows().get(i); if (selectableRow.isSelected()) { list.add(i); } } logger.info("selected: " + list.toString()); return list; }
From source file:de.ingrid.interfaces.csw.server.ServerFacade.java
/** * Generic request method/*from w ww.ja v a 2 s . c om*/ * * @param type * @param request * @throws CSWException */ protected void handleRequest(RequestType type, HttpServletRequest request, HttpServletResponse response) throws Exception { CSWMessageEncoding encodingImpl = null; try { // initialize the CSWMessageEncoding encodingImpl = this.getMessageEncodingInstance(type); encodingImpl.initialize(request, response); if (log.isDebugEnabled()) { log.debug("Handle " + type + " request"); } // validate the request message non-operation-specific encodingImpl.validateRequest(); // check if the operation is supported Operation operation = encodingImpl.getOperation(); List<Operation> supportedOperations = encodingImpl.getSupportedOperations(Type.CSW); if (!supportedOperations.contains(operation)) { StringBuffer errorMsg = new StringBuffer(); errorMsg.append("The operation '" + operation + "' is not supported in a " + type + " request.\n"); errorMsg.append("Supported values:\n"); errorMsg.append(supportedOperations.toString() + "\n"); throw new CSWOperationNotSupportedException(errorMsg.toString(), String.valueOf(operation)); } if (log.isDebugEnabled()) { log.debug("Operation: " + encodingImpl.getOperation()); } // initialize the CSWRequest instance CSWRequest requestImpl = this.getRequestInstance(operation); requestImpl.initialize(encodingImpl); // validate the request message operation-specific requestImpl.validate(); // check the CSWServer instance if (this.cswServerImpl == null) { throw new RuntimeException("ServerFacade is not configured properly: cswServerImpl is not set."); } // perform the requested operation Document result = null; if (operation == Operation.GET_CAPABILITIES) { String variant = request.getParameter( ApplicationProperties.get(ConfigurationKeys.QUERY_PARAMETER_2_CAPABILITIES_VARIANT, "")); result = this.cswServerImpl.process((GetCapabilitiesRequest) requestImpl, variant); } else if (operation == Operation.DESCRIBE_RECORD) { result = this.cswServerImpl.process((DescribeRecordRequest) requestImpl); } else if (operation == Operation.GET_DOMAIN) { result = this.cswServerImpl.process((GetDomainRequest) requestImpl); } else if (operation == Operation.GET_RECORDS) { result = this.cswServerImpl.process((GetRecordsRequest) requestImpl); } else if (operation == Operation.GET_RECORD_BY_ID) { result = this.cswServerImpl.process((GetRecordByIdRequest) requestImpl); } if (log.isDebugEnabled()) { log.debug("Result: " + StringUtils.nodeToString(result)); } // serialize the response encodingImpl.writeResponse(result); } catch (Exception e) { try { log.debug(e.getMessage(), e); if (encodingImpl != null) { encodingImpl.reportError(e); } } catch (IOException ioe) { log.error("Unable to send error message to client: " + ioe.getMessage()); } } }
From source file:it.sayservice.platform.smartplanner.cache.annotated.AnnotatedReader.java
private String getEqString(List<String> eqs, String agencyId) { List<String> sEqus = new ArrayList<String>(eqs); Collections.sort(sEqus);//w w w .j a v a2s . com String eq = sEqus.toString(); eq = eq.replaceAll(agencyId, "").replaceAll("[_ ]", "").replaceAll(",", ";").replaceAll("[\\[\\]]", ""); return Hashing.sha1().hashString(eq, Charset.forName("UTF-8")).toString(); }
From source file:at.ac.tuwien.auto.iotsys.gateway.connectors.bacnet.BacnetDeviceLoaderImpl.java
public ArrayList<Connector> initDevices(ObjectBroker objectBroker) { setConfiguration(devicesConfig);/*from w w w . ja va 2s . c om*/ objectBroker.getConfigDb().prepareDeviceLoader(getClass().getName()); ArrayList<Connector> connectors = new ArrayList<Connector>(); List<JsonNode> connectorsFromDb = objectBroker.getConfigDb().getConnectors("bacnet"); int connectorsSize = 0; // bacnet if (connectorsFromDb.size() <= 0) { Object bacnetConnectors = devicesConfig.getProperty("bacnet.connector.name"); if (bacnetConnectors != null) { connectorsSize = 1; } else { connectorsSize = 0; } if (bacnetConnectors instanceof Collection<?>) { connectorsSize = ((Collection<?>) bacnetConnectors).size(); } } else connectorsSize = connectorsFromDb.size(); for (int connector = 0; connector < connectorsSize; connector++) { HierarchicalConfiguration subConfig = devicesConfig .configurationAt("bacnet.connector(" + connector + ")"); Object bacnetConfiguredDevices = subConfig.getProperty("device.type"); String connectorId = ""; String connectorName = subConfig.getString("name"); String broadcastAddress = subConfig.getString("broadcastAddress"); int localPort = subConfig.getInteger("localPort", 3671); int localDeviceID = subConfig.getInteger("localDeviceID", 12345); boolean enabled = subConfig.getBoolean("enabled", false); Boolean groupCommEnabled = subConfig.getBoolean("groupCommEnabled", null); Boolean historyEnabled = subConfig.getBoolean("historyEnabled", null); try { connectorId = connectorsFromDb.get(connector).get("_id").asText(); connectorName = connectorsFromDb.get(connector).get("name").asText(); enabled = connectorsFromDb.get(connector).get("enabled").asBoolean(); groupCommEnabled = connectorsFromDb.get(connector).get("groupCommEnabled").asBoolean(); historyEnabled = connectorsFromDb.get(connector).get("historyEnabled").asBoolean(); broadcastAddress = connectorsFromDb.get(connector).get("broadcastAddress").asText(); localPort = connectorsFromDb.get(connector).get("localPort").asInt(); localDeviceID = connectorsFromDb.get(connector).get("localDeviceID").asInt(); } catch (Exception e) { log.info("Cannot fetch configuration from Database, using devices.xml"); } if (enabled) { try { BACnetConnector bacnetConnector = new BACnetConnector(localDeviceID, broadcastAddress, localPort); bacnetConnector.setName(connectorName); bacnetConnector.setTechnology("bacnet"); bacnetConnector.setEnabled(enabled); Obj bacRoot = bacnetConnector.getRootObj(); bacRoot.setName(connectorName); bacRoot.setHref(new Uri(connectorName.replaceAll("[^a-zA-Z0-9-~\\(\\)]", ""))); objectBroker.addObj(bacRoot, true); // Transition step: Moving configs to DB: all connector enabled, uncomment when done //bacnetConnector.connect(); Boolean discoveryEnabled = subConfig.getBoolean("discovery-enabled", false); if (discoveryEnabled) bacnetConnector.discover( new DeviceDiscoveryListener(objectBroker, groupCommEnabled, historyEnabled)); connectors.add(bacnetConnector); int numberOfDevices = 0; List<Device> devicesFromDb = objectBroker.getConfigDb().getDevices(connectorId); if (connectorsFromDb.size() <= 0) { // TODO: bacnetConfiguredDevices is from devices.xml --> mismatch when a connector does not have any device associated, // e.g., bacnet a-lab (auto) connector // do like this for other device loaders! if (bacnetConfiguredDevices != null) { numberOfDevices = 1; // there is at least one device. } if (bacnetConfiguredDevices instanceof Collection<?>) { Collection<?> bacnetDevices = (Collection<?>) bacnetConfiguredDevices; numberOfDevices = bacnetDevices.size(); } } else numberOfDevices = devicesFromDb.size(); log.info(numberOfDevices + " BACnet devices found in configuration for connector " + connectorName); // Transition step: comment when done for (int i = 0; i < numberOfDevices; i++) { String type = subConfig.getString("device(" + i + ").type"); List<Object> address = subConfig.getList("device(" + i + ").address"); String addressString = address.toString(); String ipv6 = subConfig.getString("device(" + i + ").ipv6"); String href = subConfig.getString("device(" + i + ").href"); // device specific setting Boolean historyEnabledDevice = subConfig.getBoolean("device(" + i + ").historyEnabled", null); if (historyEnabledDevice != null) { historyEnabled = historyEnabledDevice; } // device specific setting Boolean groupCommEnabledDevice = subConfig.getBoolean("device(" + i + ").groupCommEnabled", null); if (groupCommEnabledDevice != null) { // overwrite general settings groupCommEnabled = groupCommEnabledDevice; } String name = subConfig.getString("device(" + i + ").name"); String displayName = subConfig.getString("device(" + i + ").displayName"); Boolean refreshEnabled = subConfig.getBoolean("device(" + i + ").refreshEnabled", false); Integer historyCount = subConfig.getInt("device(" + i + ").historyCount", 0); Device deviceFromDb; try { deviceFromDb = devicesFromDb.get(i); type = deviceFromDb.getType(); addressString = deviceFromDb.getAddress(); String subAddr[] = addressString.substring(1, addressString.length() - 1).split(", "); address = Arrays.asList((Object[]) subAddr); ipv6 = deviceFromDb.getIpv6(); href = deviceFromDb.getHref(); name = deviceFromDb.getName(); displayName = deviceFromDb.getDisplayName(); historyEnabled = deviceFromDb.isHistoryEnabled(); groupCommEnabled = deviceFromDb.isGroupcommEnabled(); refreshEnabled = deviceFromDb.isRefreshEnabled(); historyCount = deviceFromDb.getHistoryCount(); } catch (Exception e) { } // Transition step: comment when done Device d = new Device(type, ipv6, addressString, href, name, displayName, historyCount, historyEnabled, groupCommEnabled, refreshEnabled); objectBroker.getConfigDb().prepareDevice(connectorName, d); if (type != null && address != null) { // now follow possible multiple data points // identified through // the device Id, object type, the instance number and the // property identifier, which shall be packaged into an BacnetDatapointInfo object ObjectIdentifier[] objectIdentifier = new ObjectIdentifier[(address.size()) / 4]; PropertyIdentifier[] propertyIdentifier = new PropertyIdentifier[(address.size()) / 4]; BacnetDataPointInfo[] bacnetDataPointInfo = new BacnetDataPointInfo[(address.size()) / 4]; int q = 0; for (int p = 0; p <= address.size() - 4; p += 4) { int remoteDeviceID = Integer.parseInt((String) address.get(p)); ObjectIdentifier objIdentifier = new ObjectIdentifier( new ObjectType(Integer.parseInt((String) address.get(p + 1))), Integer.parseInt((String) address.get(p + 2))); PropertyIdentifier propIdentifier = new PropertyIdentifier( Integer.parseInt((String) address.get(p + 3))); objectIdentifier[q] = objIdentifier; propertyIdentifier[q] = propIdentifier; bacnetDataPointInfo[q] = new BacnetDataPointInfo(remoteDeviceID, objIdentifier, propIdentifier); q = q + 1; } Object[] args = new Object[q + 1]; args[0] = bacnetConnector; // args[1] = Integer.parseInt(remoteDeviceID); for (int p = 0; p < bacnetDataPointInfo.length; p++) { args[1 + p] = bacnetDataPointInfo[p]; } try { Constructor<?>[] declaredConstructors = Class.forName(type) .getDeclaredConstructors(); for (int k = 0; k < declaredConstructors.length; k++) { if (declaredConstructors[k].getParameterTypes().length == args.length) { // constructor // that // takes // the // KNX // connector // and // group // address // as // argument Obj bacnetDevice = (Obj) declaredConstructors[k].newInstance(args); // create // a // instance // of // the // specified // KNX // device bacnetDevice.setHref( new Uri(URLEncoder.encode(connectorName, "UTF-8") + "/" + href)); if (name != null && name.length() > 0) { bacnetDevice.setName(name); } if (displayName != null && displayName.length() > 0) { bacnetDevice.setDisplayName(displayName); } if (ipv6 != null) { objectBroker.addObj(bacnetDevice, ipv6); } else { objectBroker.addObj(bacnetDevice); } myObjects.add(bacnetDevice); bacnetDevice.initialize(); if (historyEnabled != null && historyEnabled) { if (historyCount != null && historyCount != 0) { objectBroker.addHistoryToDatapoints(bacnetDevice, historyCount); } else { objectBroker.addHistoryToDatapoints(bacnetDevice); } } if (refreshEnabled != null && refreshEnabled) { objectBroker.enableObjectRefresh(bacnetDevice); } if (groupCommEnabled != null && groupCommEnabled) { objectBroker.enableGroupComm(bacnetDevice); } } } } catch (SecurityException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } } } } catch (Exception e) { e.printStackTrace(); } } } return connectors; }
From source file:com.google.api.ads.adwords.awreporting.model.definitions.AbstractReportDefinitionTest.java
/** * Tests the properties that will be selected for the report. *///from w w w. jav a2s . co m @Test public void testReportProperties() { List<String> propertiesToSelect = this.csvReportEntitiesMapping.retrievePropertiesToSelect(this.reportType); Assert.assertNotNull(propertiesToSelect); String[] reportProperties = this.retrievePropertiesToBeSelected(); Assert.assertEquals( "The number of properties mapped is different from the properties specified on the test.\n" + "expected: " + Arrays.toString(reportProperties) + "\nfound: " + propertiesToSelect.toString(), reportProperties.length, propertiesToSelect.size()); for (int i = 0; i < reportProperties.length; i++) { Assert.assertTrue(propertiesToSelect.contains(reportProperties[i])); } }