Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to the Apache Software Foundation (ASF) under one
   * or more contributor license agreements.  See the NOTICE file
   * distributed with this work for additional information
   * regarding copyright ownership.  The ASF licenses this file
   * to you under the Apache License, Version 2.0 (the
   * "License"); you may not use this file except in compliance
   * with the License.  You may obtain a copy of the License at
   * 
  *   http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.    
  */
 
 package org.apache.tuscany.sca.contribution.java.impl;
 
 import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
 
 
Artifact processor for Java Export

Version:
$Rev: 889531 $ $Date: 2009-12-11 10:26:48 +0200 (Fri, 11 Dec 2009) $
 
 public class JavaExportProcessor implements StAXArtifactProcessor<JavaExport> {
     private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
     
     private static final QName EXPORT_JAVA = new QName("export.java");
     
     private static final String PACKAGE = "package";
     
     private final JavaImportExportFactory factory;
     
     public JavaExportProcessor(FactoryExtensionPoint modelFactories) {
         super();
         this. = modelFactories.getFactory(JavaImportExportFactory.class);
     }
    
    
Report a error.

Parameters:
problems
message
model
 
      private void error(Monitor monitorString messageObject modelObject... messageParameters) {
     	 if (monitor != null) {
 	        Problem problem = monitor.createProblem(this.getClass().getName(), "contribution-java-validation-messages".modelmessage, (Object[])messageParameters);
 	        monitor.problem(problem);
     	 }
      }
      
     public QName getArtifactType() {
         return ;
     }
     
     public Class<JavaExportgetModelType() {
         return JavaExport.class;
     }
    
    
Process <export package=""/>
 
     public JavaExport read(XMLStreamReader readerProcessorContext contextthrows ContributionReadException {
         JavaExport javaExport = this..createJavaExport();
         QName element = null;
         
         try {
             while (reader.hasNext()) {
                 int event = reader.getEventType();
                 switch (event) {
                     case :
                         element = reader.getName();
                         
                         // Read <export.java>
                         if (.equals(element)) {
                            String packageName = reader.getAttributeValue(null);
                            if (packageName == null) {
                            	error(context.getMonitor(), "AttributePackageMissing"reader);
                                //throw new ContributionReadException("Attribute 'package' is missing");
                            } else                        
                                javaExport.setPackage(packageName);
                        }
                        break;
                    case .:
                        if (.equals(reader.getName())) {
                            return javaExport;
                        }
                        break;        
                }
                
                //Read the next element
                if (reader.hasNext()) {
                    reader.next();
                }
            }
        }
        catch (XMLStreamException e) {
            ContributionReadException ex = new ContributionReadException(e);
            error(context.getMonitor(), "XMLStreamException"readerex);
        }
        
        return javaExport;
    }
    public void write(JavaExport javaExportXMLStreamWriter writerProcessorContext contextthrows ContributionWriteExceptionXMLStreamException {
        
        // Write <export.java>
        
        if (javaExport.getPackage() != null) {
            writer.writeAttribute(javaExport.getPackage());
        }
        
        writer.writeEndElement();
    }
    public void resolve(JavaExport javaExportModelResolver resolverProcessorContext contextthrows ContributionResolveException {
        
        if (javaExport.getPackage() != null)
            // Initialize the export resolver
            javaExport.setModelResolver(new JavaExportModelResolver(javaExportresolver));
    }
New to GrepCode? Check out our FAQ X