Package org.apache.excalibur.source

Examples of org.apache.excalibur.source.TraversableSource


                            }
                        });
                    } else if (sort.equals("collection")) {
                        Arrays.sort(contents.toArray(), new Comparator() {
                            public int compare(Object o1, Object o2) {
                                TraversableSource ts1 = (TraversableSource) o1;
                                TraversableSource ts2 = (TraversableSource) o2;

                                if (reverse) {
                                    if (ts2.isCollection() && !ts1.isCollection())
                                        return -1;
                                    if (!ts2.isCollection() && ts1.isCollection())
                                        return 1;
                                    return ts2.getName().compareTo(ts1.getName());
                                }
                                if (ts2.isCollection() && !ts1.isCollection())
                                    return 1;
                                if (!ts2.isCollection() && ts1.isCollection())
                                    return -1;
                                return ts1.getName().compareTo(ts2.getName());
                            }
                        });
                    }

                    for (int i = 0; i < contents.size(); i++) {
View Full Code Here


        }

        public TraversableSourceMeta(Source source) throws SourceException {
            super(source);

            final TraversableSource tsource = (TraversableSource) source;

            setName(tsource.getName());
            setIsCollection(tsource.isCollection());

            if (isCollection()) {
                final Collection children = tsource.getChildren();
                if (children != null) {
                    final String[] names = new String[children.size()];
                    final Iterator iter = children.iterator();
                    int count = 0;
                    while(iter.hasNext()) {
                        TraversableSource child = (TraversableSource) iter.next();
                        names[count] = child.getName();
                        count++;
                    }
                    setChildren(names);
                }
            }
View Full Code Here

    /*
     * Adjust the traversable source so that it use the block name as name instead of
     * e.g. the directory name from the source that the block name was resolved to.
     */
    private static Source adjustName(final TraversableSource source, final String blockName) {
        TraversableSource adjustedSource =
            (TraversableSource) Proxy.newProxyInstance(source.getClass().getClassLoader(), ClassUtils.getAllInterfaces(source),
                new InvocationHandler() {

                    /* (non-Javadoc)
                     * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
View Full Code Here

            }
          });
        } else if (sort.equals("collection")) {
          Arrays.sort(contents.toArray(), new Comparator() {
            public int compare(Object o1, Object o2) {
              TraversableSource ts1 = (TraversableSource)o1;
              TraversableSource ts2 = (TraversableSource)o2;

              if (reverse) {
                if (ts2.isCollection() && !ts1.isCollection())
                  return -1;
                if (!ts2.isCollection() && ts1.isCollection())
                  return 1;
                return ts2.getName().compareTo(ts1.getName());
              }
              if (ts2.isCollection() && !ts1.isCollection())
                return 1;
              if (!ts2.isCollection() && ts1.isCollection())
                return -1;
              return ts1.getName().compareTo(ts2.getName());
            }
          });
        }

        for (int i = 0; i < contents.size(); i++) {
View Full Code Here

     * @throws  SAXException if an error occurs while outputting the document
     * @throws  ProcessingException if something went wrong while traversing
     *                              the source hierarchy
     */
    public void generate() throws SAXException, ProcessingException {
        TraversableSource inputSource = null;
        try {
            inputSource = (TraversableSource) this.resolver.resolveURI(this.source);

            if (!inputSource.isCollection()) {
                throw new ResourceNotFoundException(this.source + " is not a collection.");
            }

            this.contentHandler.startDocument();

View Full Code Here

     *
     * @param source the traversable source whose ancestors shall be retrieved
     * @return a Stack containing the ancestors.
     */
    protected Stack getAncestors(TraversableSource source) throws IOException {
        TraversableSource parent = source;
        Stack ancestors = new Stack();

        while ((parent != null) && !isRoot(parent)) {
            parent = (TraversableSource) parent.getParent();
            if (parent != null) {
                ancestors.push(parent);
            } else {
                // no ancestor matched the root pattern
                ancestors.clear();
View Full Code Here

                        }
                    });
                } else if (sort.equals("collection")) {
                    Arrays.sort(contents.toArray(), new Comparator() {
                        public int compare(Object o1, Object o2) {
                            TraversableSource ts1 = (TraversableSource) o1;
                            TraversableSource ts2 = (TraversableSource) o2;

                            if (reverse) {
                                if (ts2.isCollection() && !ts1.isCollection())
                                    return -1;
                                if (!ts2.isCollection() && ts1.isCollection())
                                    return 1;
                                return ts2.getName().compareTo(ts1.getName());
                            }
                            if (ts2.isCollection() && !ts1.isCollection())
                                return 1;
                            if (!ts2.isCollection() && ts1.isCollection())
                                return -1;
                            return ts1.getName().compareTo(ts2.getName());
                        }
                    });
                }

                for (int i = 0; i < contents.size(); i++) {
View Full Code Here

            }

            expiry = System.currentTimeMillis() + delay;
            int len = sources.size();
            for (int i = 0; i < len; i++) {
                TraversableSource ts =  (TraversableSource) sources.get(i);
                if (!ts.exists()) {
                    return -1; // Source was removed
                }

                long oldDate = ((Long) sourcesDates.get(i)).longValue();
                long newDate = ts.getLastModified();

                if (oldDate != newDate) {
                    return -1;
                }
            }
View Full Code Here

        try {
            src = this.resolver.resolveURI(this.source);
            if (!(src instanceof TraversableSource)) {
                throw new SourceException(this.source + " is not a traversable source");
            }
            final TraversableSource inputSource = (TraversableSource) src;

            if (!inputSource.exists()) {
                throw new ResourceNotFoundException(this.source + " does not exist.");
            }

            this.contentHandler.startDocument();
            this.contentHandler.startPrefixMapping(PREFIX, URI);
View Full Code Here

     *
     * @param source the traversable source whose ancestors shall be retrieved
     * @return a Stack containing the ancestors.
     */
    protected Stack getAncestors(TraversableSource source) throws IOException {
        TraversableSource parent = source;
        Stack ancestors = new Stack();

        while ((parent != null) && !isRoot(parent)) {
            parent = (TraversableSource) parent.getParent();
            if (parent != null) {
                ancestors.push(parent);
            } else {
                // no ancestor matched the root pattern
                ancestors.clear();
View Full Code Here

TOP

Related Classes of org.apache.excalibur.source.TraversableSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.