1 /*
2 * ModeShape (http://www.modeshape.org)
3 * See the COPYRIGHT.txt file distributed with this work for information
4 * regarding copyright ownership. Some portions may be licensed
5 * to Red Hat, Inc. under one or more contributor license agreements.
6 * See the AUTHORS.txt file in the distribution for a full listing of
7 * individual contributors.
8 *
9 * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
10 * is licensed to you under the terms of the GNU Lesser General Public License as
11 * published by the Free Software Foundation; either version 2.1 of
12 * the License, or (at your option) any later version.
13 *
14 * ModeShape is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this software; if not, write to the Free
21 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
23 */
24 package org.modeshape.example.sequencer;
25
26 import java.util.List;
27 import java.util.Map;
28 import java.util.Properties;
29 import java.util.TreeMap;
30 import net.jcip.annotations.Immutable;
31
32 /**
33 * The information about Java source.
34 */
35 @Immutable
36 public class JavaInfo extends ContentInfo {
37
38 private final Map<String, List<Properties>> javaElements;
39 private final String type;
40
41 protected JavaInfo( String path,
42 String name,
43 String type,
44 Map<String, List<Properties>> javaElements ) {
45 super(path, name, null);
46 this.type = type;
47 this.javaElements = javaElements != null ? new TreeMap<String, List<Properties>>(javaElements) : new TreeMap<String, List<Properties>>();
48 }
49
50 public String getType() {
51 return this.type;
52 }
53
54 /**
55 * @return javaElements
56 */
57 public Map<String, List<Properties>> getJavaElements() {
58 return javaElements;
59 }
60
61 @Override
62 public String toString() {
63 StringBuilder sb = new StringBuilder();
64 sb.append(" Name: " + getName() + "\n");
65 sb.append(" Path: " + getPath() + "\n");
66 sb.append(" Type: " + getType() + "\n");
67 for (Map.Entry<Object, Object> entry : getProperties().entrySet()) {
68 sb.append(" " + entry.getKey() + ": " + entry.getValue() + "\n");
69 }
70 for (Map.Entry<String, List<Properties>> javaElement : getJavaElements().entrySet()) {
71 sb.append("\n ------ " + javaElement.getKey() + " ------\n");
72 for (Properties props : javaElement.getValue()) {
73 for (Map.Entry<Object, Object> entry : props.entrySet()) {
74 if (!entry.getKey().equals("jcr:primaryType")) {
75 sb.append(" " + entry.getKey() + " => " + entry.getValue() + "\n");
76 }
77 }
78 }
79 }
80 return sb.toString();
81 }
82
83 }