Autopsy  4.19.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
RejTreeKeyNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy
3  *
4  * Copyright 2019 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Copyright 2013 Willi Ballenthin
8  * Contact: willi.ballenthin <at> gmail <dot> com
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  */
22 package org.sleuthkit.autopsy.rejview;
23 
24 import com.williballenthin.rejistry.RegistryKey;
25 import com.williballenthin.rejistry.RegistryParseException;
26 import com.williballenthin.rejistry.RegistryValue;
27 import java.io.UnsupportedEncodingException;
28 import java.util.Iterator;
29 import java.util.LinkedList;
30 import java.util.List;
31 import java.util.logging.Level;
32 import org.openide.util.NbBundle.Messages;
34 
38 public final class RejTreeKeyNode implements RejTreeNode {
39 
40  private static final Logger logger = Logger.getLogger(RejTreeKeyNode.class.getName());
41  private final RegistryKey key;
42 
43  public RejTreeKeyNode(RegistryKey key) {
44  this.key = key;
45  }
46 
47  @Messages({"RejTreeKeyNode.parseFailed.string=PARSE FAILED."})
48  @Override
49  public String toString() {
50  try {
51  return this.key.getName();
52  } catch (UnsupportedEncodingException ex) {
53  logger.log(Level.WARNING, "Failed to parse key name", ex);
54  return Bundle.RejTreeKeyNode_parseFailed_string();
55  }
56  }
57 
58  @Override
59  public boolean hasChildren() {
60  try {
61  return this.key.getValueList().size() > 0 || this.key.getSubkeyList().size() > 0;
62  } catch (RegistryParseException ex) {
63  logger.log(Level.WARNING, "Failed to parse key children.", ex);
64  return false;
65  }
66  }
67 
68  @Override
69  public List<RejTreeNode> getChildren() {
70  LinkedList<RejTreeNode> children = new LinkedList<>();
71 
72  try {
73  Iterator<RegistryKey> keyit = this.key.getSubkeyList().iterator();
74  while (keyit.hasNext()) {
75  children.add(new RejTreeKeyNode(keyit.next()));
76  }
77 
78  Iterator<RegistryValue> valueit = this.key.getValueList().iterator();
79  while (valueit.hasNext()) {
80  children.add(new RejTreeValueNode(valueit.next()));
81  }
82  } catch (RegistryParseException ex) {
83  logger.log(Level.WARNING, "Failed to parse key children.", ex);
84  }
85  return children;
86  }
87 
91  RegistryKey getKey() {
92  return this.key;
93  }
94 
95  @Override
97  return new RejTreeKeyView(this);
98  }
99 }
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2021 Basis Technology. Generated on: Thu Sep 30 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.