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.jackrabbit.spi2dav;
 
 
 
 import java.util.List;
 import java.util.Map;

EventImpl...
 
 public class EventImpl
         extends org.apache.jackrabbit.spi.commons.EventImpl
         implements ObservationConstants {
 
     private static Logger log = LoggerFactory.getLogger(EventImpl.class);
 
     private static final NameFactory N_FACTORY = NameFactoryImpl.getInstance();
 
     public EventImpl(ItemId eventIdPath eventPathNodeId parentIdint eventTypeString userId,
             Element eventElementNamePathResolver resolverQValueFactory qvFactorythrows NamespaceException,
             IllegalNameException {
         super(getSpiEventType(eventType), eventPatheventIdparentIdgetNameSafe(
                 DomUtil.getChildTextTrim(eventElement), resolver), getNames(
                 DomUtil.getChildren(eventElement), resolver), userId, DomUtil.getChildTextTrim(
                 eventElement), Long.parseLong(DomUtil.getChildTextTrim(eventElement)),
                 getEventInfo(DomUtil.getChildElement(eventElement), resolverqvFactory));
     }
 
     //--------------------------------------------------------------------------
     private static int getSpiEventType(int jcrEventType) {
         switch (jcrEventType) {
             case ....:
                 return .;
             case ....:
                 return .;
             case ....:
                 return .;
             case ....:
                 return .;
             case ....:
                 return .;
             case ....:
                 return .;
             case ....:
                 return .;
             default:
                 throw new IllegalArgumentException("Invalid event type: " + jcrEventType);
         }
     }
 
     private static Map<NameQValuegetEventInfo(Element infoElement,
                                                   NamePathResolver resolver,
                                                   QValueFactory qvFactory) {
         if (infoElement == null) {
             return Collections.emptyMap();
         }
 
         Map<NameQValueinfo = new HashMap<NameQValue>();
        ElementIterator it = DomUtil.getChildren(infoElement);
        while (it.hasNext()) {
            Element el = it.nextElement();
            String uri = el.getNamespaceURI();
            if (uri == null) {
                uri = ..getURI();
            }
            String localName = el.getLocalName();
            String value = DomUtil.getTextTrim(el);
            try {
                Name n = .create(urilocalName);
                QValue qv = null;
                if (value != null) {
                    qv = ValueFormat.getQValue(value.resolverqvFactory);
                }
                info.put(nqv);
            } catch (RepositoryException e) {
                .error("Internal Error: "e.getMessage());
            }
        }
        return info;
    }
    private static Name getNameSafe(String nameNamePathResolver resolverthrows IllegalNameExceptionNamespaceException {
        if (name == null) {
            return null;
        }
        else {
            return resolver.getQName(name);
        }
    }
    private static Name[] getNames(ElementIterator elements,
            NamePathResolver resolver) {
        List<Nameresults = Collections.emptyList();
        while (elements.hasNext()) {
            String rawname = DomUtil.getText(elements.nextElement());
            Name name = null;
            try {
                name = resolver.getQName(rawname);
                if (results.size() == 0) {
                    results = Collections.singletonList(name);
                } else if (results.size() == 1) {
                    results = new ArrayList<Name>(results);
                    results.add(name);
                } else {
                    results.add(name);
                }
            } catch (Exception ex) {
                .error("Exception converting name " + rawnameex);
            }
        }
        return results.toArray(new Name[results.size()]);
    }
New to GrepCode? Check out our FAQ X