List of usage examples for java.lang System identityHashCode
@HotSpotIntrinsicCandidate public static native int identityHashCode(Object x);
From source file:IK.AbstractBone.java
public AbstractBone(AbstractBone par, //parent bone double xAngle, //how much the bone should be pitched relative to its parent bone double yAngle, //how much the bone should be rolled relative to its parent bone double zAngle, //how much the bone should be yawed relative to its parent bone String inputTag, //some user specified name for the bone, if desired double inputBoneHeight //bone length ) throws NullParentForBoneException { if (par != null) { if (this.tag == null || this.tag == "") { this.tag = Integer.toString(System.identityHashCode(this)); } else//from w w w . j a v a2s . c o m this.tag = inputTag; this.boneHeight = inputBoneHeight; AbstractAxes tempAxes = par.localAxes().getAbsoluteCopy(); Rotation toRot = new Rotation(RotationOrder.XZY, xAngle, yAngle, zAngle); Rot newRot = new Rot(); newRot.rotation = toRot; tempAxes.rotateTo(newRot); this.parent = par; this.parentArmature = this.parent.parentArmature; parentArmature.addToBoneList(this); generateAxes(parent.getTip(), tempAxes.x().heading(), tempAxes.y().heading(), tempAxes.z().heading()); this.localAxes.orthogonalize(); localAxes.setParent(parent.localAxes); previousOrientation = localAxes.attachedCopy(true); majorRotationAxes = parent.localAxes().getAbsoluteCopy(); majorRotationAxes.translateTo(parent.getTip()); majorRotationAxes.setParent(parent.localAxes); this.parent.addFreeChild(this); this.parent.addChild(this); this.updateSegmentedArmature(); } else { throw new NullParentForBoneException(); } }
From source file:org.apache.cayenne.log.CommonsJdbcEventLogger.java
void sqlLiteralForObject(StringBuilder buffer, Object object) { if (object == null) { buffer.append("NULL"); } else if (object instanceof String) { buffer.append('\''); // lets escape quotes String literal = (String) object; if (literal.length() > TRIM_VALUES_THRESHOLD) { literal = literal.substring(0, TRIM_VALUES_THRESHOLD) + "..."; }// www . j a va 2 s . co m int curPos = 0; int endPos = 0; while ((endPos = literal.indexOf('\'', curPos)) >= 0) { buffer.append(literal.substring(curPos, endPos + 1)).append('\''); curPos = endPos + 1; } if (curPos < literal.length()) buffer.append(literal.substring(curPos)); buffer.append('\''); } // handle byte pretty formatting else if (object instanceof Byte) { IDUtil.appendFormattedByte(buffer, ((Byte) object).byteValue()); } else if (object instanceof Number) { // process numeric value (do something smart in the future) buffer.append(object); } else if (object instanceof java.sql.Date) { buffer.append('\'').append(object).append('\''); } else if (object instanceof java.sql.Time) { buffer.append('\'').append(object).append('\''); } else if (object instanceof java.util.Date) { long time = ((java.util.Date) object).getTime(); buffer.append('\'').append(new java.sql.Timestamp(time)).append('\''); } else if (object instanceof java.util.Calendar) { long time = ((java.util.Calendar) object).getTimeInMillis(); buffer.append(object.getClass().getName()).append('(').append(new java.sql.Timestamp(time)).append(')'); } else if (object instanceof Character) { buffer.append(((Character) object).charValue()); } else if (object instanceof Boolean) { buffer.append('\'').append(object).append('\''); } else if (object instanceof Enum<?>) { // buffer.append(object.getClass().getName()).append("."); buffer.append(((Enum<?>) object).name()).append("="); if (object instanceof ExtendedEnumeration) { Object value = ((ExtendedEnumeration) object).getDatabaseValue(); if (value instanceof String) buffer.append("'"); buffer.append(value); if (value instanceof String) buffer.append("'"); } else { buffer.append(((Enum<?>) object).ordinal()); // FIXME -- this isn't quite right } } else if (object instanceof SQLParameterBinding) { sqlLiteralForObject(buffer, ((SQLParameterBinding) object).getValue()); } else if (object.getClass().isArray()) { buffer.append("< "); int len = Array.getLength(object); boolean trimming = false; if (len > TRIM_VALUES_THRESHOLD) { len = TRIM_VALUES_THRESHOLD; trimming = true; } for (int i = 0; i < len; i++) { if (i > 0) { buffer.append(","); } sqlLiteralForObject(buffer, Array.get(object, i)); } if (trimming) { buffer.append("..."); } buffer.append('>'); } else { buffer.append(object.getClass().getName()).append("@").append(System.identityHashCode(object)); } }
From source file:ObjectUtils.java
/** * <p>Appends the toString that would be produced by <code>Object</code> * if a class did not override toString itself. <code>null</code> * will throw a NullPointerException for either of the two parameters. </p> * * <pre>/*w w w.j a v a 2 s . c om*/ * ObjectUtils.identityToString(buf, "") = buf.append("java.lang.String@1e23" * ObjectUtils.identityToString(buf, Boolean.TRUE) = buf.append("java.lang.Boolean@7fa" * ObjectUtils.identityToString(buf, Boolean.TRUE) = buf.append("java.lang.Boolean@7fa") * </pre> * * @param buffer the buffer to append to * @param object the object to create a toString for * @since 2.4 */ public static void identityToString(StringBuffer buffer, Object object) { if (object == null) { throw new NullPointerException("Cannot get the toString of a null identity"); } buffer.append(object.getClass().getName()).append('@') .append(Integer.toHexString(System.identityHashCode(object))); }
From source file:org.eclipse.smila.utils.xml.XMLUtils.java
/** * A 32 byte GUID generator (Globally Unique ID). These artificial keys SHOULD <strong>NOT </strong> be seen by the * user, not even touched by the DBA but with very rare exceptions, just manipulated by the database and the programs. * //from w w w .j a v a 2 s .c o m * Usage: Add an id field (type java.lang.String) to your EJB, and add setId(XXXUtil.generateGUID(this)); to the * ejbCreate method. * * @return String * @param o * - */ public static final String generateGUID(Object o) { final Log log = LogFactory.getLog(XMLUtils.class); final StringBuffer tmpBuffer = new StringBuffer(16); if (s_hexServerIP == null) { java.net.InetAddress localInetAddress = null; try { // get the inet address localInetAddress = java.net.InetAddress.getLocalHost(); } catch (final java.net.UnknownHostException uhe) { if (log.isErrorEnabled()) { log.error( "ConfigurationUtil: Could not get the local IP address using InetAddress.getLocalHost()!", uhe); } return null; } final byte[] serverIP = localInetAddress.getAddress(); s_hexServerIP = hexFormat(getInt(serverIP), 8); } final String hashcode = hexFormat(System.identityHashCode(o), 8); tmpBuffer.append(s_hexServerIP); tmpBuffer.append(hashcode); final long timeNow = System.currentTimeMillis(); final int timeLow = (int) timeNow & 0xFFFFFFFF; final int node = SEEDER.nextInt(); final StringBuffer guid = new StringBuffer(32); guid.append(hexFormat(timeLow, 8)); guid.append(tmpBuffer.toString()); guid.append(hexFormat(node, 8)); return guid.toString(); }
From source file:nz.co.senanque.vaadinsupport.application.MaduraSessionManager.java
public void deregister(AbstractComponent field) { m_fields.remove(System.identityHashCode(field)); m_labels.remove(System.identityHashCode(field)); }
From source file:org.droid2droid.install.DownloadApkActivity.java
private void setDialog(Intent intent) { int id = intent.getIntExtra(Notifications.EXTRA_ID, -1); DownloadFile df = mTransInfo = AbstractSrvRemoteAndroid.getDowloadFile(id); Log.d(TAG_INSTALL, PREFIX_LOG + "setDialog intent=" + System.identityHashCode(intent) + " id=" + id); assert df != null; if (df == null) { if (E)//w w w . jav a 2s.co m Log.e(TAG_INSTALL, PREFIX_LOG + "ERROR phatom id " + id + " when want to open DownloadApkActivity"); return; } mLine1.setText(getString(R.string.download_line1, df.from)); mLine2.setText(getString(R.string.download_line2, df.label)); mLine3.setText(getString(R.string.download_line3, Formatter.formatFileSize(this, df.size))); mLine5.setText(getString(R.string.download_line5)); onProgressUpdate(); }
From source file:org.envirocar.app.storage.DbAdapterImpl.java
/** * @param ctx the used android context/* w w w . j a v a 2 s.c o m*/ * @param maxTimeBetweenMeasurements maximum time between two measurements (ms). if * the difference is higher, a new track is created for the new measurement * @param maxDistanceBetweenMeasurements maximum distance between two measurements (km). if * the distance is higher, a new track is created for the new measurement * @throws InstantiationException if the connection to the database fails */ public static void init(Context ctx, long maxTimeBetweenMeasurements, double maxDistanceBetweenMeasurements) throws InstantiationException { instance = new DbAdapterImpl(ctx); instance.maxTimeBetweenMeasurements = maxTimeBetweenMeasurements; instance.maxDistanceBetweenMeasurements = maxDistanceBetweenMeasurements; instance.openConnection(); logger.info("init DbAdapterImpl; Hash: " + System.identityHashCode(instance)); }
From source file:com.lizardtech.expresszip.model.Job.java
public Job(ExportProps param, ExportOptionsViewComponent view) { jobParams = param;/*from w ww .jav a2 s .c o m*/ parent = view; url = view.getApplication().getMainWindow().getURL(); if (exportDir == null) { exportDir = new File(ExpressZipApplication.Configuration.getProperty("exportdirectory"), jobParams.getJobName()); exportDir.mkdir(); } String JobRunID = String.format("%d", System.identityHashCode(this)); logger = Logger.getLogger(JobRunID); logger.setAdditivity(false); try { outputLogFile = new File(exportDir, getLogName()); outputLogAppender = new FileAppender(new HTMLLayout(), outputLogFile.getPath()); logger.addAppender(outputLogAppender); } catch (IOException e) { BasicConfigurator.configure(); } // Set up GeoTIFF writer compression and tiling geoTiffWPs = new GeoTiffWriteParams(); geoTiffWPs.setCompressionMode(GeoTiffWriteParams.MODE_EXPLICIT); geoTiffWPs.setCompressionType("LZW"); geoTiffWPs.setCompressionQuality(0.75F); geoTiffWPs.setTilingMode(GeoTiffWriteParams.MODE_EXPLICIT); geoTiffWPs.setTiling(256, 256); }
From source file:org.apache.geode.internal.util.ArrayUtils.java
public static String objectRefString(Object obj) { return obj != null ? obj.getClass().getSimpleName() + '@' + Integer.toHexString(System.identityHashCode(obj)) : "(null)"; }
From source file:gdsc.smlm.ij.plugins.EMGainAnalysis.java
/** * Random sample from the cumulative probability distribution function that is used during fitting * /*from w w w . j a v a2 s . c o m*/ * @return The histogram */ private int[] simulateFromPDF() { final double[] g = pdf(0, _photons, _gain, _noise, (int) _bias); // Get cumulative probability double sum = 0; for (int i = 0; i < g.length; i++) { final double p = g[i]; g[i] += sum; sum += p; } for (int i = 0; i < g.length; i++) g[i] /= sum; g[g.length - 1] = 1; // Ensure value of 1 at the end // Randomly sample RandomGenerator random = new Well44497b(System.currentTimeMillis() + System.identityHashCode(this)); int[] h = new int[g.length]; final int steps = simulationSize; for (int n = 0; n < steps; n++) { if (n % 64 == 0) IJ.showProgress(n, steps); final double p = random.nextDouble(); for (int i = 0; i < g.length; i++) if (p <= g[i]) { h[i]++; break; } } return h; }