Databoard Tutorials

From Developer Documents
Revision as of 10:47, 7 September 2011 by Toni Kalajainen (talk | contribs) (Created page with "This document contains a some Java coding snippets for Databoard. # Object Deep-Copy The binding class can be used for cloning objects. The copies are <syntaxHighlight lang="ja...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This document contains a some Java coding snippets for Databoard.

  1. Object Deep-Copy

The binding class can be used for cloning objects. The copies are <syntaxHighlight lang="java"> // Binding can copy objects. All copies are deep. // Mutable objects are duplicated, immutable are referenced.

// For instance, in object array, the array is copied, but its // immutable literal instances (e.g. 1) is referenced.

Object[] original = new Object[] { new Object(), 1, "X", 123.456 }; Binding binding = Bindings.getBinding( original.getClass() ); Object[] copy = (Object[]) binding.cloneUnchecked( original );

// Print the objects System.out.println( "Original: "+binding.toString( original ) ); System.out.println( "Clone : "+binding.toString( copy ) ); </syntaxHighlight>


  1. Object Deep-Compare