List of usage examples for java.io Serializable hashCode
@HotSpotIntrinsicCandidate public native int hashCode();
From source file:com.sirma.itt.emf.properties.entity.PropertyValue.java
@Override public int hashCode() { int h = 0;/* www .j a v a2 s. co m*/ if (actualType != null) { h = actualType.hashCode(); } Serializable persistedValue = getPersistedValue(); if (persistedValue != null) { h += 17 * persistedValue.hashCode(); } return h; }
From source file:org.alfresco.serializers.PropertyValue.java
@Override public int hashCode() { int h = 0;/*w w w . j av a 2s . c o m*/ if (actualType != null) h = actualType.hashCode(); Serializable persistedValue = getPersistedValue(); if (persistedValue != null) h += 17 * persistedValue.hashCode(); return h; }
From source file:org.audit4j.core.AsyncAuditEngine.java
/** * Send./* w w w . jav a 2 s .c o m*/ * * @param t * the t */ public void send(final Serializable t) { try { final MessageProducer producer = session.createProducer(destination); producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); final ObjectMessage objectMessage = session.createObjectMessage(); objectMessage.setObject(t); // Tell the producer to send the message System.out.println("Sent message: " + t.hashCode()); producer.send(objectMessage); } catch (final Exception e) { System.out.println("Caught: " + e); e.printStackTrace(); } }
From source file:org.rhq.enterprise.server.plugins.rhnhosted.PrimaryXML.java
/** * Will create a xml string snippet conforming to the <package> entry in a primary.xml file used by yum * * @param pkg JAXB Object to transform/*from w ww. j ava2 s . c o m*/ * @return string snippet of xml data */ static public String createPackageXML(RhnPackageType pkg) { Namespace packageNS = Namespace.getNamespace(RHNHOSTED_URI); Element top = new Element("package", packageNS); top.setAttribute("type", "rpm"); Element name = new Element("name", packageNS); name.setText(pkg.getName()); top.addContent(name); Element arch = new Element("arch", packageNS); arch.setText(pkg.getPackageArch()); top.addContent(arch); Element version = new Element("version", packageNS); version.setText(pkg.getVersion()); version.setAttribute("ver", pkg.getVersion()); version.setAttribute("rel", pkg.getRelease()); String epoch = pkg.getEpoch(); // Note, if epoch is empty we need to change it to a zero as that is what yum expects. if (StringUtils.isBlank(epoch)) { epoch = "0"; } version.setAttribute("epoch", epoch); top.addContent(version); Element checksum = new Element("checksum", packageNS); checksum.setAttribute("type", "md5"); checksum.setAttribute("pkgid", "YES"); checksum.setText(pkg.getMd5Sum()); top.addContent(checksum); Element summary = new Element("summary", packageNS); summary.setText(pkg.getRhnPackageSummary()); top.addContent(summary); Element description = new Element("description", packageNS); description.setText(pkg.getRhnPackageDescription()); top.addContent(description); Element packager = new Element("packager", packageNS); //TODO: Not sure if we get 'packager' info from RHN. packager.setText(""); top.addContent(packager); Element url = new Element("url", packageNS); //TODO: Not sure what to put for url value, don't think it applies to RHN url.setText(""); top.addContent(url); Element time = new Element("time", packageNS); //TODO: Verify below, guessing for file/build times. time.setAttribute("file", pkg.getLastModified()); time.setAttribute("build", pkg.getBuildTime()); top.addContent(time); Element size = new Element("size", packageNS); size.setAttribute("package", pkg.getPackageSize()); size.setAttribute("archive", pkg.getPayloadSize()); //TODO: Unsure about installed, does this need to change on server side when package is installed on a client? size.setAttribute("installed", ""); top.addContent(size); Element location = new Element("location", packageNS); //This value can not be empty and can not contain a "?". //It's value is ignored by the RHQ processing for yum. //RHQ will append a series of request parameters to download the file. String rpmName = RHNHelper.constructRpmDownloadName(pkg.getName(), pkg.getVersion(), pkg.getRelease(), pkg.getEpoch(), pkg.getPackageArch()); location.setAttribute("href", rpmName); top.addContent(location); Element format = new Element("format", packageNS); Namespace rpmNS = Namespace.getNamespace("rpm", "http://rhq-project.org/rhnhosted"); Element rpmLicense = new Element("license", rpmNS); rpmLicense.setText(pkg.getRhnPackageCopyright()); format.addContent(rpmLicense); Element rpmVendor = new Element("vendor", rpmNS); rpmVendor.setText(pkg.getRhnPackageVendor()); format.addContent(rpmVendor); Element rpmGroup = new Element("group", rpmNS); rpmGroup.setText(pkg.getPackageGroup()); format.addContent(rpmGroup); Element rpmBuildHost = new Element("buildhost", rpmNS); rpmBuildHost.setText(pkg.getBuildHost()); format.addContent(rpmBuildHost); Element rpmSourceRPM = new Element("sourcerpm", rpmNS); rpmSourceRPM.setText(pkg.getSourceRpm()); format.addContent(rpmSourceRPM); Element rpmHeaderRange = new Element("header-range", rpmNS); rpmHeaderRange.setAttribute("start", pkg.getRhnPackageHeaderStart()); rpmHeaderRange.setAttribute("end", pkg.getRhnPackageHeaderEnd()); format.addContent(rpmHeaderRange); Element rpmProvides = new Element("provides", rpmNS); RhnPackageProvidesType provides_type = pkg.getRhnPackageProvides(); if (provides_type != null) { List<RhnPackageProvidesEntryType> provides = provides_type.getRhnPackageProvidesEntry(); for (RhnPackageProvidesEntryType provEntry : provides) { Element entry = new Element("entry", rpmNS); entry.setAttribute("name", provEntry.getName()); String flags = getFlags(provEntry.getSense()); if (!StringUtils.isBlank(flags)) { entry.setAttribute("flags", flags); String provEpoch = getEpoch(provEntry.getVersion()); entry.setAttribute("epoch", provEpoch); String provVer = getVersion(provEntry.getVersion()); entry.setAttribute("ver", provVer); String provRel = getRelease(provEntry.getVersion()); entry.setAttribute("rel", getRelease(provEntry.getVersion())); } rpmProvides.addContent(entry); } } format.addContent(rpmProvides); Element rpmRequires = new Element("requires", rpmNS); RhnPackageRequiresType requires_type = pkg.getRhnPackageRequires(); if (requires_type != null) { List<RhnPackageRequiresEntryType> requires = requires_type.getRhnPackageRequiresEntry(); for (RhnPackageRequiresEntryType reqEntry : requires) { Element entry = new Element("entry", rpmNS); entry.setAttribute("name", reqEntry.getName()); String flags = getFlags(reqEntry.getSense()); if (!StringUtils.isBlank(flags)) { entry.setAttribute("flags", flags); String reqEpoch = getEpoch(reqEntry.getVersion()); entry.setAttribute("epoch", reqEpoch); String reqVer = getVersion(reqEntry.getVersion()); entry.setAttribute("ver", reqVer); String reqRel = getRelease(reqEntry.getVersion()); entry.setAttribute("rel", getRelease(reqEntry.getVersion())); } rpmRequires.addContent(entry); } } format.addContent(rpmRequires); Element rpmConflicts = new Element("conflicts", rpmNS); rpmConflicts.setText(pkg.getRhnPackageConflicts()); format.addContent(rpmConflicts); Element rpmObsoletes = new Element("obsoletes", rpmNS); RhnPackageObsoletesType obs_type = pkg.getRhnPackageObsoletes(); if (obs_type != null) { List<Serializable> obsoletes = obs_type.getContent(); for (Serializable s : obsoletes) { RhnPackageObsoletesEntryType obsEntry = null; if (s instanceof String) { String obsString = (String) s; if (StringUtils.isBlank(obsString)) { continue; } //log.debug("Adding Obsoletes info <String Class> value = " + obsString); Element entry = new Element("entry", rpmNS); entry.setAttribute("name", obsString); rpmObsoletes.addContent(entry); // skip rest of obs processing for this entry continue; } // // Below obs entry processing is for JAXBElement types only // if (s instanceof JAXBElement) { JAXBElement je = (JAXBElement) s; //log.debug("Processing obsolete info for JAXBElement of type : " + je.getDeclaredType()); obsEntry = (RhnPackageObsoletesEntryType) je.getValue(); } else if (s instanceof RhnPackageObsoletesEntryType) { obsEntry = (RhnPackageObsoletesEntryType) s; } else { log.info("Processing obsoletes info: unable to determine what class obsoletes entry is: " + "getClass() = " + s.getClass() + ", toString() = " + s.toString() + ", hashCode = " + s.hashCode()); continue; } Element entry = new Element("entry", rpmNS); entry.setAttribute("name", obsEntry.getName()); String obsVer = obsEntry.getVersion(); if (!StringUtils.isBlank(obsVer)) { entry.setAttribute("version", obsVer); } String obsFlags = getFlags(obsEntry.getSense()); if (!StringUtils.isBlank(obsFlags)) { entry.setAttribute("flags", obsFlags); } rpmObsoletes.addContent(entry); } } format.addContent(rpmObsoletes); top.addContent(format); XMLOutputter xmlOut = new XMLOutputter(); return xmlOut.outputString(top); }
From source file:org.springframework.jdbc.repo.impl.jdbc.RawPropertiesRepoImplTest.java
@Test public void testFindEntitiesByPropertyValue() { final String BASE_ID = "testFindEntitiesByPropertyValue"; Map<String, Serializable> props = createEntityProperties(BASE_ID); List<String> expected = new ArrayList<>(); for (int index = 0; index < Byte.SIZE; index++) { String id = BASE_ID + index; repo.setProperties(id, props);//from w ww. j a v a2s.com expected.add(id); } for (Map.Entry<String, Serializable> pe : props.entrySet()) { String propName = pe.getKey(); Serializable propValue = pe.getValue(); List<String> actual = repo.findEntities(propName, propValue); if (!CollectionUtils.isEqualCollection(expected, actual)) { fail("Mismatched results for " + propName + "=" + propValue + ": expected=" + expected + ", actual=" + actual); } // change the type so we know it won't matcj if (propValue instanceof String) { propValue = Integer.valueOf(propValue.hashCode()); } else { propValue = propValue.toString(); } actual = repo.findEntities(propName, propValue); if (ExtendedCollectionUtils.size(actual) > 0) { fail("Unexpected results for " + propName + "=" + propValue + ": " + actual); } } }