Showing posts with label Java dev. Show all posts
Showing posts with label Java dev. Show all posts

Saturday, 29 August 2020

public private keys

 Copy and pasting text (public/private keys) in this day in age, for security - seriously!

Tuesday, 26 August 2014

Hash Relational Mapping, Part 2

More details and a demo of the hash relational mapping functionality can be found here .
In summary it is a means of transforming a relational join based result-sets into hierarchical nested data structure, a format well suited for big-data stores.  

Thursday, 23 February 2012

Hash Relational Mapping

Or HashRelMap is a java-based database mapping mechanism  I have developed which uses multi-dimensional hash-maps to store the results of join queries. For those familiar with ORM such as Hibernate and JPA queries are stored in Pojo object.  With this method queries are stored in multi-dimensional hash-maps. More details to follow.

Friday, 23 December 2011

Hash-map to XML with recursion

public static class MapEntryConverter implements Converter {

       public boolean canConvert(Class clazz) {
               return AbstractMap.class.isAssignableFrom(clazz);
       }
       public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {
        AbstractMap map = (AbstractMap) value;
        for (Object obj : map.entrySet()) {
               Entry entry = (Entry) obj;
               writer.startNode(entry.getKey().toString());
               if (entry.getValue() instanceof HashMap) {
                   marshal(entry.getValue(), writer, context);

               } else {
                   writer.setValue(entry.getValue().toString());
               }
               writer.endNode();
           }      
       }
      
       public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
           Map<String, Object> map = new HashMap<String, Object>();

           while(reader.hasMoreChildren()) {
                   reader.moveDown();
                   map.put(reader.getNodeName(), reader.getValue());
                   reader.moveUp();
               }
               return map;
           }

    }


The code shown above is based on the Xstream code provided in this link from stackoverflow.com. A recursive call is added to take account of nested Hashmaps.