List of usage examples for java.util TreeSet add
public boolean add(E e)
From source file:com.qpark.maven.plugin.springintegration.TestClientGeneratorMojo.java
/** * @see org.apache.maven.plugin.Mojo#execute() */// w ww . j a v a 2 s . c o m @Override public void execute() throws MojoExecutionException, MojoFailureException { StaticLoggerBinder.getSingleton().setLog(this.getLog()); this.getLog().debug("+execute"); this.getLog().debug("get xsds"); XsdsUtil xsds = XsdsUtil.getInstance(this.baseDirectory, this.basePackageName, this.messagePackageNameSuffix, this.deltaPackageNameSuffix, this.serviceRequestSuffix, this.serviceResponseSuffix); String eipVersion = this.getEipVersion(); TestClientGenerator tc; Collection<String> serviceIds = ServiceIdRegistry.splitServiceIds(this.serviceId); if (serviceIds.size() == 0) { serviceIds = xsds.getServiceIdRegistry().getAllServiceIds(); } this.getLog().info("ServiceId size " + serviceIds.size()); TreeSet<String> configImports = new TreeSet<String>(); StringBuffer configClients = new StringBuffer(); for (String sid : serviceIds) { this.getLog().info("ServiceId " + sid); StringBuffer sb = new StringBuffer(1024); TreeSet<String> imports = new TreeSet<String>(); imports.add("javax.xml.bind.JAXBElement"); imports.add("org.springframework.ws.client.core.support.WebServiceGatewaySupport"); StringBuffer impl = new StringBuffer(); String s; String packageName = this.basePackageName; String objectFactoryClassName = ""; String contextPathName = ""; for (ElementType element : xsds.getElementTypes()) { if (element.isRequest() && element.getServiceId().equals(sid)) { tc = new TestClientGenerator(xsds, element, this.useSpringInsightAnnotation, eipVersion, this.getLog()); s = tc.generate(); if (s.length() > 0) { if (packageName == null || packageName.trim().length() == 0) { packageName = element.getPackageNameGateway().replace(".gateway", ".client"); } objectFactoryClassName = new StringBuffer(element.getPackageName()).append(".ObjectFactory") .toString(); contextPathName = element.getPackageName(); impl.append("\n").append(s); imports.addAll(tc.getImports()); imports.add(objectFactoryClassName); } } } if (impl.length() > 0) { String className = new StringBuffer().append(Util.getXjcClassName(sid)).append("ServiceClient") .toString(); configClients.append(this.generateClientServiceConfig(className)); configImports.add(new StringBuffer(packageName).append(".").append(className).toString()); if (packageName.length() > 0) { sb.append("package "); sb.append(packageName); sb.append(";\n"); sb.append("\n"); } for (String imported : imports) { if (imported != null && imported.trim().length() > 0) { sb.append("import "); sb.append(imported); sb.append(";\n"); } } sb.append("/**\n"); sb.append(" * Client implementation of service <code>"); sb.append(sid); sb.append("</code> using\n"); sb.append(" * the {@link WebServiceGatewaySupport}.\n"); sb.append(Util.getGeneratedAtJavaDocClassHeader(this.getClass(), eipVersion)); sb.append(" */\n"); sb.append("public class "); sb.append(className); sb.append(" extends WebServiceGatewaySupport {\n"); sb.append("\t/** The {@link org.springframework.oxm.jaxb.Jaxb2Marshaller}s context path. */\n"); sb.append("\tpublic static final String CONTEXT_PATH_NAME = \""); sb.append(contextPathName); sb.append("\";\n"); sb.append("\t/** The service id. */\n"); sb.append("\tpublic static final String SERVICE_ID = \""); sb.append(sid); sb.append("\";\n"); sb.append("\t/** Service {@link ObjectFactory}. */\n"); sb.append("\tprivate final ObjectFactory objectFactory = new ObjectFactory();\n"); sb.append("\n"); sb.append("\t/**\n"); sb.append("\t * @return the {@link ObjectFactory} of the service.\n"); sb.append("\t */\n"); sb.append("\tpublic ObjectFactory getObjectFactory() {\n"); sb.append("\t\treturn this.objectFactory;\n"); sb.append("\t}\n"); sb.append("\n"); sb.append(impl); sb.append("}\n"); File f = Util.getFile(this.outputDirectory, packageName, new StringBuffer(className).append(".java").toString()); this.getLog().info(new StringBuffer().append("Write ").append(f.getAbsolutePath())); try { Util.writeToFile(f, sb.toString()); } catch (Exception e) { this.getLog().error(e.getMessage()); e.printStackTrace(); } } } this.generateAbstractConfig(xsds, this.basePackageName, configClients.toString(), configImports); this.generateClientWss4jSecurityInterceptor(xsds, this.basePackageName); this.getLog().debug("-execute"); }
From source file:com.sfs.whichdoctor.dao.ReportDAOImpl.java
/** * Builds the author order string./*from w w w.ja v a2 s .c o m*/ * * @param authors the authors * @return the string */ private String buildAuthorOrder(final List<PersonBean> authors) { StringBuilder sb = new StringBuilder(); TreeSet<String> order = new TreeSet<String>(); if (authors != null) { for (PersonBean person : authors) { order.add(person.getLastName() + "," + person.getFirstName()); } } for (String item : order) { if (sb.length() > 0) { sb.append("-"); } sb.append(item); } return sb.toString(); }
From source file:net.pms.dlna.protocolinfo.DLNAOrgPlaySpeeds.java
/** * For internal use only, use {@link #FACTORY} to create new instances. * * @param speeds the play-speed values./*from ww w . j av a2 s . c o m*/ */ private DLNAOrgPlaySpeeds(Rational... speeds) { TreeSet<Rational> speedSet = new TreeSet<>(); for (Rational speed : speeds) { if (speed != null && !Rational.ONE.equals(speed)) { speedSet.add(speed); } } this.speeds = Collections.unmodifiableSortedSet(speedSet); this.stringValue = generateStringValue(this.speeds); this.hashCode = calculateHashCode(); }
From source file:jfs.sync.JFSElement.java
/** * Returns the valid actions for the JFS element. * * @return A vector of valid synchronization actions. *//*from w w w . java 2 s .c o m*/ public TreeSet<SyncAction> getValidActions() { TreeSet<SyncAction> validActions = new TreeSet<>(); if (state == ElementState.IS_ROOT) { return validActions; } validActions.add(SyncAction.NOP); if (srcFile != null) { validActions.add(SyncAction.COPY_SRC); } else { validActions.add(SyncAction.DELETE_TGT); } if (tgtFile != null) { validActions.add(SyncAction.COPY_TGT); } else { validActions.add(SyncAction.DELETE_SRC); } if (srcFile != null && tgtFile != null) { validActions.add(SyncAction.DELETE_SRC_AND_TGT); } return validActions; }
From source file:net.pms.dlna.protocolinfo.DLNAOrgPlaySpeeds.java
/** * For internal use only, use {@link #FACTORY} to create new instances. * * @param speeds the play-speed values.//from w ww.ja v a 2s . c o m */ private DLNAOrgPlaySpeeds(SortedSet<Rational> speedSet) { TreeSet<Rational> newSpeedsSet = new TreeSet<>(); for (Rational speed : speedSet) { if (speed != null && !Rational.ONE.equals(speed)) { newSpeedsSet.add(speed); } } speeds = Collections.unmodifiableSortedSet(newSpeedsSet); stringValue = generateStringValue(speeds); hashCode = calculateHashCode(); }
From source file:$.MessageController.java
/** * Creates a set of message dates, to search logs for these dates. * This set contains just the dates of the following timestamps: * <ul>//from www.j a v a 2s . c om * <li>source system timestamp</li> * <li>received timestamp</li> * <li>start processing timestamp</li> * <li>last update timestamp</li> * </ul> * It's a Set, so that only distinct dates will be included. * It's a SortedSet, so that the dates are in their natural order. * The elements are LocalDate (without time), * so that the dates will be in the correct order * and the set will correctly not include duplicates. * * @param msg the message to find dates for * @return a set of dates */ private SortedSet<LocalDate> getMsgDates(Message msg) { TreeSet<LocalDate> logDates = new TreeSet<LocalDate>(); Date[] msgDates = new Date[] { msg.getMsgTimestamp(), msg.getReceiveTimestamp(), msg.getStartProcessTimestamp(), msg.getLastUpdateTimestamp() }; for (Date msgDate : msgDates) { if (msgDate != null) { logDates.add(new LocalDate(msgDate)); } } return logDates; }
From source file:net.spfbl.core.Reverse.java
public static TreeSet<String> getAddressSet(String hostname) throws NamingException { if ((hostname = Domain.normalizeHostname(hostname, false)) == null) { return null; } else {/*from ww w . j a v a 2 s. c o m*/ TreeSet<String> ipSet = new TreeSet<String>(); Attributes attributesA = Server.getAttributesDNS(hostname, new String[] { "A" }); if (attributesA != null) { Enumeration enumerationA = attributesA.getAll(); while (enumerationA.hasMoreElements()) { Attribute attributeA = (Attribute) enumerationA.nextElement(); NamingEnumeration enumeration = attributeA.getAll(); while (enumeration.hasMoreElements()) { String address = (String) enumeration.next(); if (SubnetIPv4.isValidIPv4(address)) { address = SubnetIPv4.normalizeIPv4(address); ipSet.add(address); } } } } Attributes attributesAAAA = Server.getAttributesDNS(hostname, new String[] { "AAAA" }); if (attributesAAAA != null) { Enumeration enumerationAAAA = attributesAAAA.getAll(); while (enumerationAAAA.hasMoreElements()) { Attribute attributeAAAA = (Attribute) enumerationAAAA.nextElement(); NamingEnumeration enumeration = attributeAAAA.getAll(); while (enumeration.hasMoreElements()) { String address = (String) enumeration.next(); if (SubnetIPv6.isValidIPv6(address)) { address = SubnetIPv6.normalizeIPv6(address); ipSet.add(address); } } } } return ipSet; } }
From source file:jease.Registry.java
private void initDomainTypes(Set<String> domainClasses) { List<Content> contentList = new ArrayList<>(); TreeSet<Property> propertyList = new TreeSet<>(Comparator.comparing(Property::getType)); for (String domainClass : domainClasses) { Object obj = Reflections.newInstance(domainClass); if (Content.class.isInstance(obj)) { contentList.add((Content) obj); }/*w w w . j a va 2 s. com*/ if (Property.class.isInstance(obj)) { propertyList.add((Property) obj); } } contentList.sort(Comparator.comparing(Content::getType)); contents = contentList.toArray(new Content[contentList.size()]); properties = propertyList; }
From source file:com.dare2date.externeservice.lastfm.LastfmAPI.java
/** * Makes a call to an external Lastfm service and processes this set of LastfmEvent objects. * @param username The user from whom the event will be requested. * @return A LastfmData object from a specific user, which hold data from all visited last fm events. */// w w w . j a v a 2 s .c o m public TreeSet<LastfmEvent> getUserEventHistory(String username) { TreeSet<LastfmEvent> result = new TreeSet<LastfmEvent>(); String response = httpClient.get("http://ws.audioscrobbler.com/2.0/?method=user.getpastevents&user=" + username + "&api_key=" + apiKey + "&format=JSON"); if (response != null) { try { List<JSONObject> eventsData = JsonPath.read(response, "$..event"); for (JSONObject eventData : eventsData) { result.add(createEventFromJSONData(eventData)); } } catch (ParseException e) { e.printStackTrace(); } } return result; }
From source file:com.google.android.marvin.mytalkback.speechrules.NodeSpeechRuleProcessor.java
/** * Returns a sorted set of {@code node}'s direct children. *//*from ww w .j a va 2s .co m*/ private TreeSet<AccessibilityNodeInfoCompat> getSortedChildren(AccessibilityNodeInfoCompat node) { final TreeSet<AccessibilityNodeInfoCompat> children = new TreeSet<AccessibilityNodeInfoCompat>(COMPARATOR); for (int i = 0; i < node.getChildCount(); i++) { final AccessibilityNodeInfoCompat child = node.getChild(i); if (child == null) { continue; } children.add(child); } return children; }