001 /*
002 * JBoss DNA (http://www.jboss.org/dna)
003 * See the COPYRIGHT.txt file distributed with this work for information
004 * regarding copyright ownership. Some portions may be licensed
005 * to Red Hat, Inc. under one or more contributor license agreements.
006 * See the AUTHORS.txt file in the distribution for a full listing of
007 * individual contributors.
008 *
009 * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
010 * is licensed to you under the terms of the GNU Lesser General Public License as
011 * published by the Free Software Foundation; either version 2.1 of
012 * the License, or (at your option) any later version.
013 *
014 * JBoss DNA is distributed in the hope that it will be useful,
015 * but WITHOUT ANY WARRANTY; without even the implied warranty of
016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017 * Lesser General Public License for more details.
018 *
019 * You should have received a copy of the GNU Lesser General Public
020 * License along with this software; if not, write to the Free
021 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
022 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
023 */
024 package org.jboss.example.dna.sequencer;
025
026 import java.util.List;
027 import java.util.Map;
028 import java.util.Properties;
029 import java.util.TreeMap;
030 import net.jcip.annotations.Immutable;
031
032 /**
033 * @author Serge Pagop
034 * @author Randall Hauch
035 */
036 @Immutable
037 public class JavaInfo extends ContentInfo {
038
039 private final Map<String, List<Properties>> javaElements;
040 private final String type;
041
042 protected JavaInfo( String path,
043 String name,
044 String type,
045 Map<String, List<Properties>> javaElements ) {
046 super(path, name, null);
047 this.type = type;
048 this.javaElements = javaElements != null ? new TreeMap<String, List<Properties>>(javaElements) : new TreeMap<String, List<Properties>>();
049 }
050
051 public String getType() {
052 return this.type;
053 }
054
055 /**
056 * @return javaElements
057 */
058 public Map<String, List<Properties>> getJavaElements() {
059 return javaElements;
060 }
061
062 @Override
063 public String toString() {
064 StringBuilder sb = new StringBuilder();
065 sb.append(" Name: " + getName() + "\n");
066 sb.append(" Path: " + getPath() + "\n");
067 sb.append(" Type: " + getType() + "\n");
068 for (Map.Entry<Object, Object> entry : getProperties().entrySet()) {
069 sb.append(" " + entry.getKey() + ": " + entry.getValue() + "\n");
070 }
071 for (Map.Entry<String, List<Properties>> javaElement : getJavaElements().entrySet()) {
072 sb.append("\n ------ " + javaElement.getKey() + " ------\n");
073 for (Properties props : javaElement.getValue()) {
074 for (Map.Entry<Object, Object> entry : props.entrySet()) {
075 if (!entry.getKey().equals("jcr:primaryType")) {
076 sb.append(" " + entry.getKey() + " => " + entry.getValue() + "\n");
077 }
078 }
079 }
080 }
081 return sb.toString();
082 }
083
084 }