abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dand...@apache.org
Subject svn commit: r634477 - in /incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/employee: Employee.java EmployeeCollectionAdapter.java
Date Fri, 07 Mar 2008 00:23:37 GMT
Author: dandiep
Date: Thu Mar  6 16:23:29 2008
New Revision: 634477

URL: http://svn.apache.org/viewvc?rev=634477&view=rev
Log:
snippet info

Modified:
    incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/employee/Employee.java
    incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/employee/EmployeeCollectionAdapter.java

Modified: incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/employee/Employee.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/employee/Employee.java?rev=634477&r1=634476&r2=634477&view=diff
==============================================================================
--- incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/employee/Employee.java
(original)
+++ incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/employee/Employee.java
Thu Mar  6 16:23:29 2008
@@ -2,6 +2,7 @@
 
 import java.util.Date;
 
+// START SNIPPET: employee
 public class Employee {
   private int id;
   private String name;
@@ -25,3 +26,4 @@
     this.updated = updated;
   }
 }
+// END SNIPPET: employee
\ No newline at end of file

Modified: incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/employee/EmployeeCollectionAdapter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/employee/EmployeeCollectionAdapter.java?rev=634477&r1=634476&r2=634477&view=diff
==============================================================================
--- incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/employee/EmployeeCollectionAdapter.java
(original)
+++ incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/employee/EmployeeCollectionAdapter.java
Thu Mar  6 16:23:29 2008
@@ -26,7 +26,7 @@
   private AtomicInteger nextId = new AtomicInteger(1000);
   private Map<Integer, Employee> employees = new HashMap<Integer, Employee>();
   private Factory factory = new Abdera().getFactory();
-  
+  // START SNIPPET: feedmetadata
   /**
    * A unique ID for this feed.
    */
@@ -47,55 +47,12 @@
   public String getAuthor(RequestContext request) {
     return "Acme Industries";
   }
+  // END SNIPPET: feedmetadata
   
-  @Override
-  public Employee postEntry(String title, IRI id, String summary, 
-                            Date updated, List<Person> authors,
-                            Content content, RequestContext request) throws ResponseContextException
{   
-    Employee employee = contentToCustomer(content);
-    employees.put(employee.getId(), employee);
-    
-    return employee;
-  }
-
-  private Employee contentToCustomer(Content content) {
-    Employee employee = new Employee();
-    
-    return contentToCustomer(content, employee);
-  }
-
-  private Employee contentToCustomer(Content content, Employee employee) {
-    Element firstChild = content.getFirstChild();
-    employee.setName(firstChild.getAttributeValue("name"));
-    employee.setId(nextId.incrementAndGet());
-    return employee;
-  }
-
-  public void deleteEntry(String resourceName, RequestContext request) throws ResponseContextException
{
-    Integer id = getIdFromResourceName(resourceName);
-    employees.remove(id);
-  }
-
-  @Override
-  public List<Person> getAuthors(Employee entry, RequestContext request) throws ResponseContextException
{
-    Person author = request.getAbdera().getFactory().newAuthor();
-    author.setName("Acme Industries");
-    return Arrays.asList(author);
-  }
-
-  public Object getContent(Employee entry, RequestContext request) {
-    Content content = factory.newContent();
-    Element employeeEl = factory.newElement(new QName("employee"));
-    employeeEl.setAttributeValue(new QName("name"), entry.getName());
-   
-    content.setValueElement(employeeEl);
-    return content;
-  }
-
   public Iterable<Employee> getEntries(RequestContext request) {
     return employees.values();
   }
-
+  // START SNIPPET: getEntry
   public Employee getEntry(String resourceName, RequestContext request) throws ResponseContextException
{
     Integer id = getIdFromResourceName(resourceName);
     return employees.get(id);
@@ -108,7 +65,8 @@
     }
     return new Integer(resourceName.substring(0, idx));
   }
-
+  // END SNIPPET: getEntry
+  // START SNIPPET: entryMetadata
   public String getId(Employee entry) {
     return ID_PREFIX + entry.getId();
   }
@@ -124,11 +82,53 @@
     return entry.getUpdated();
   }
 
-  @Override
+  public List<Person> getAuthors(Employee entry, RequestContext request) throws ResponseContextException
{
+    Person author = request.getAbdera().getFactory().newAuthor();
+    author.setName("Acme Industries");
+    return Arrays.asList(author);
+  }
+
+  public Object getContent(Employee entry, RequestContext request) {
+    Content content = factory.newContent();
+    Element employeeEl = factory.newElement(new QName("employee"));
+    employeeEl.setAttributeValue(new QName("name"), entry.getName());
+   
+    content.setValueElement(employeeEl);
+    return content;
+  }
+  // END SNIPPET: entryMetadata
+  // START SNIPPET: methods
+  public Employee postEntry(String title, IRI id, String summary, 
+                            Date updated, List<Person> authors,
+                            Content content, RequestContext request) throws ResponseContextException
{   
+    Employee employee = contentToEmployee(content);
+    employees.put(employee.getId(), employee);
+    
+    return employee;
+  }
+  
   public void putEntry(Employee entry, String title, Date updated, 
                        List<Person> authors, String summary,
                        Content content, RequestContext request) throws ResponseContextException
{
-    contentToCustomer(content, entry);
+    contentToEmployee(content, entry);
+  }
+
+  public void deleteEntry(String resourceName, RequestContext request) throws ResponseContextException
{
+    Integer id = getIdFromResourceName(resourceName);
+    employees.remove(id);
   }
 
+  private Employee contentToEmployee(Content content) {
+    Employee employee = new Employee();
+    
+    return contentToEmployee(content, employee);
+  }
+
+  private Employee contentToEmployee(Content content, Employee employee) {
+    Element firstChild = content.getFirstChild();
+    employee.setName(firstChild.getAttributeValue("name"));
+    employee.setId(nextId.incrementAndGet());
+    return employee;
+  }
+  // END SNIPPET: methods
 }



Mime
View raw message