<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Sample6</title><link>https://sourceforge.net/p/scfjava/wiki/Sample6/</link><description>Recent changes to Sample6</description><atom:link href="https://sourceforge.net/p/scfjava/wiki/Sample6/feed" rel="self"/><language>en</language><lastBuildDate>Mon, 22 Oct 2012 23:00:27 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/scfjava/wiki/Sample6/feed" rel="self" type="application/rss+xml"/><item><title>WikiPage Sample6 modified by scf</title><link>https://sourceforge.net/p/scfjava/wiki/Sample6/</link><description>&lt;pre&gt;--- v1
+++ v2
@@ -1,6 +1,10 @@
 ### Abstract ###
 
 This sample show us how to use the **ReflexionUtils** class in order to charge properties from a **Object** to a **Map** and also from a **Map** to an **Object**.
+
+---
+
+Este ejemplo nos muestra cómo utilizar la clase **ReflexionUtils** para cargar propiedades desde un **Object** a un **Map** y en sentido inverso desde un **Map** a un **Object**.
 
 ### Author.java ###
 ~~~~~~
&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">scf</dc:creator><pubDate>Mon, 22 Oct 2012 23:00:27 -0000</pubDate><guid>https://sourceforge.net33e23e89d4eb0201730a767aeccc5474972a4bcd</guid></item><item><title>WikiPage Sample6 modified by scf</title><link>https://sourceforge.net/p/scfjava/wiki/Sample6/</link><description>### Abstract ###

This sample show us how to use the **ReflexionUtils** class in order to charge properties from a **Object** to a **Map** and also from a **Map** to an **Object**.

### Author.java ###
~~~~~~
:::java

package ar.com.scf.sample06;

public class Author {

  private int birth_year;

  private String name;

  public Author(String name, int birth_year) {
    setName(name);
    setBirth_year(birth_year);
  }

  public int getBirth_year() {
    return birth_year;
  }

  public String getName() {
    return name;
  }

  public void setBirth_year(int birth_year) {
    this.birth_year = birth_year;
  }

  public void setName(String name) {
    this.name = name;
  }

  @Override
  public String toString() {
    return getName();
  }
}

~~~~~~

---
### Book.java ###
~~~~~~
:::java

package ar.com.scf.sample06;

public class Book {

  private Author author;

  private String ISBN;

  private float price;

  private String title;

  public Book(String title, Author author, float price, String ISBN) {
    setTitle(title);
    setAuthor(author);
    setPrice(price);
    setISBN(ISBN);
  }

  public Author getAuthor() {
    return author;
  }

  public String getISBN() {
    return ISBN;
  }

  public float getPrice() {
    return price;
  }

  public String getTitle() {
    return title;
  }

  public void setAuthor(Author author) {
    this.author = author;
  }

  public void setISBN(String iSBN) {
    ISBN = iSBN;
  }

  public void setPrice(float price) {
    this.price = price;
  }

  public void setTitle(String title) {
    this.title = title;
  }

  @Override
  public String toString() {
    return getTitle() + ", " + getAuthor() + " [" + getISBN() + "], $" + getPrice();
  }
}

~~~~~~

---
### Sample.java ###
~~~~~~
:::java

package ar.com.scf.sample06;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

import ar.com.scf.utils.ReflexionUtils;

public class Sample {

  public static void main(String[] args) throws Exception {
    Author verne = new Author("Jules Gabriel Verne", 1828);
    Book book = new Book("De la Tierra a la Luna", verne, 32.0f, "9788420731940");

    ReflexionUtils util = new ReflexionUtils();
    Map&lt;String, Object&gt; target = new HashMap&lt;String, Object&gt;();

    util.charge(book, target);

    for (Entry&lt;String, Object&gt; entry : target.entrySet())
      System.out.println(entry.getKey() + ": " + entry.getValue());

    System.out.println("---x---");

    Map&lt;String, Object&gt; source = new HashMap&lt;String, Object&gt;(target);
    source.put("Title", "20.000 leguas de viaje submarino");
    source.put("ISBN", "9686769749");

    Book book2 = new Book(null, null, 0, null);
    util.charge(source, book2);
    System.out.println(book2);
  }

}
~~~~~~

---
### output ###
~~~~~~
:::console

ISBN: 9788420731940
Price: 32.0
Author: Jules Gabriel Verne
Title: De la Tierra a la Luna
---x---
20.000 leguas de viaje submarino, Jules Gabriel Verne [9686769749], $32.0
~~~~~~</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">scf</dc:creator><pubDate>Thu, 18 Oct 2012 21:39:59 -0000</pubDate><guid>https://sourceforge.net28a2cbaad27c899d5841f553cde55ccb8676821d</guid></item></channel></rss>