Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source.
   * Copyright 2008, Red Hat Middleware LLC, and individual contributors
   * as indicated by the @author tags. See the copyright.txt file in the
   * distribution for a full listing of individual contributors.
   *
   * 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.jboss.as.connector.util;
 
 import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
 import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
 import static org.jboss.as.controller.parsing.ParseUtils.requireSingleAttribute;
 
 import java.util.Map;
 
 
A AbstractParser.

Author(s):
Stefano Maestri
 
 public abstract class AbstractParser {
    
The logger
 
     private static CommonLogger log = Logger.getMessageLogger(CommonLogger.classAbstractParser.class.getName());

    
The bundle
 
     private static CommonBundle bundle = Messages.getBundle(CommonBundle.class);



    
FIXME Comment this

Parameters:
reader
Returns:
the string representing the raw eleemnt text
Throws:
javax.xml.stream.XMLStreamException
 
     public String rawElementText(XMLStreamReader readerthrows XMLStreamException {
         String elementtext = reader.getElementText();
         elementtext = elementtext == null || elementtext.trim().length() == 0 ? null : elementtext.trim();
         return elementtext;
     }

    
FIXME Comment this

Parameters:
reader
attributeName
Returns:
the string representing raw attribute textx
 
     public String rawAttributeText(XMLStreamReader readerString attributeName) {
         String attributeString = reader.getAttributeValue(""attributeName) == null ? null : reader.getAttributeValue(
                 ""attributeName)
                 .trim();
         return attributeString;
     }
 
 
     protected void parseExtension(XMLExtendedStreamReader readerString enclosingTagfinal ModelNode operation,
                                   final SimpleAttributeDefinition extensionclassnamefinal SimpleAttributeDefinition extensionProperties)
             throws XMLStreamExceptionParserExceptionValidateException {
 
         String className = null;
         Map<StringStringproperties = null;
 
         for (Extension.Attribute attribute : Extension.Attribute.values()) {
            switch (attribute) {
                case : {
                    requireSingleAttribute(readerattribute.getLocalName());
                    final String value = reader.getAttributeValue(0);
                    extensionclassname.parseAndSetParameter(valueoperationreader);
                    break;
                }
                default:
                    break;
            }
        }
        while (reader.hasNext()) {
            switch (reader.nextTag()) {
                case : {
                    if (reader.getLocalName().equals(enclosingTag)) {
                        //It's fine doing nothing
                        return;
                    } else {
                        if (Extension.Tag.forName(reader.getLocalName()) == ..) {
                            throw new ParserException(.unexpectedEndTag(reader.getLocalName()));
                        }
                    }
                    break;
                }
                case : {
                    switch (Extension.Tag.forName(reader.getLocalName())) {
                        case : {
                            requireSingleAttribute(reader"name");
                            final String name = reader.getAttributeValue(0);
                            String value = rawElementText(reader);
                            final String trimmed = value == null ? null : value.trim();
                            ModelNode node = new ModelNode();
                            if (trimmed != null ) {
                                if (extensionProperties.isAllowExpression()) {
                                    node = ParseUtils.parsePossibleExpression(trimmed);
                                } else {
                                    node = new ModelNode().set(trimmed);
                                }
                            }
                            operation.get(extensionProperties.getName(), name).set(node);
                            break;
                        }
                        default:
                            throw new ParserException(.unexpectedElement(reader.getLocalName()));
                    }
                    break;
                }
            }
        }
        throw new ParserException(.unexpectedEndOfDocument());
    }
    private static class SecurityActions {
        
Constructor
        private SecurityActions() {
        }

        
Get a system property

Parameters:
name The property name
Returns:
The property value
        static String getSystemProperty(final String name) {
            if (System.getSecurityManager() == null) {
                return System.getProperty(name);
            } else {
                return (String) AccessController.doPrivileged(new PrivilegedAction<Object>() {
                    public Object run() {
                        return System.getProperty(name);
                    }
                });
            }
        }
    }
New to GrepCode? Check out our FAQ X