Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (C) 2009 eXo Platform SAS.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
   * the License, or (at your option) any later version.
   *
   * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 package org.exoplatform.services.jcr.ext.registry;
 
 
 
Created by The eXo Platform SAS .
Encapsulates registry entry (i.e services', applications' etc settings)

Author(s):
Gennady Azarenkov
Version:
$Id: $
 
 
 public final class RegistryEntry
 {
 
    private Document document;

   
creates a RegistryEntry after XML DOM Document root element node name it is the name of the Entry

Parameters:
dom
 
    public RegistryEntry(Document dom)
    {
       this. = dom;
    }

   
 
    {
       DocumentBuilder db =
          {
             public DocumentBuilder run() throws Exception
             {
                return DocumentBuilderFactory.newInstance().newDocumentBuilder();
             }
          });
       this. = db.newDocument();
       Element nodeElement = .createElement(rootName);
       .appendChild(nodeElement);
    }

   
Factory method to create RegistryEntry from serialized XML

 
    public static RegistryEntry parse(final byte[] bytesthrows IOExceptionSAXExceptionParserConfigurationException
    {
       try
      {
         return SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<RegistryEntry>()
         {
            public RegistryEntry run() throws Exception
            {
               return new RegistryEntry(DocumentBuilderFactory.newInstance().newDocumentBuilder()
                  .parse(new ByteArrayInputStream(bytes)));
            }
         });
      }
      catch (PrivilegedActionException pae)
      {
         Throwable cause = pae.getCause();
         if (cause instanceof ParserConfigurationException)
         {
            throw (ParserConfigurationException)cause;
         }
         else if (cause instanceof IOException)
         {
            throw (IOException)cause;
         }
         else if (cause instanceof SAXException)
         {
            throw (SAXException)cause;
         }
         else if (cause instanceof RuntimeException)
         {
            throw (RuntimeException)cause;
         }
         else
         {
            throw new RuntimeException(cause);
         }
      }
   }

   
Factory method to create RegistryEntry from stream XML

   public static RegistryEntry parse(final InputStream inthrows IOExceptionSAXException,
   {
      try
      {
         return SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<RegistryEntry>()
         {
            public RegistryEntry run() throws Exception
            {
               return new RegistryEntry(DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in));
            }
         });
      }
      catch (PrivilegedActionException pae)
      {
         Throwable cause = pae.getCause();
         if (cause instanceof ParserConfigurationException)
         {
            throw (ParserConfigurationException)cause;
         }
         else if (cause instanceof IOException)
         {
            throw (IOException)cause;
         }
         else if (cause instanceof SAXException)
         {
            throw (SAXException)cause;
         }
         else if (cause instanceof RuntimeException)
         {
            throw (RuntimeException)cause;
         }
         else
         {
            throw new RuntimeException(cause);
         }
      }
   }

   

Returns:
the entry as InputStream
Throws:
java.io.IOException
javax.xml.transform.TransformerException
   {
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      TransformerFactory.newInstance().newTransformer().transform(new DOMSource(), new StreamResult(out));
      return new ByteArrayInputStream(out.toByteArray());
   }

   

Returns:
the name of entry (which is the same as underlying Document's root name)
   public String getName()
   {
      return .getDocumentElement().getNodeName();
   }

   

Returns:
the underlying Document
   public Document getDocument()
   {
      return ;
   }
New to GrepCode? Check out our FAQ X