19 package org.sleuthkit.datamodel;
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.HashSet;
24 import java.util.List;
26 import java.util.logging.Level;
27 import java.util.logging.Logger;
40 private final long objId;
41 private final String name;
43 private String uniquePath;
46 private volatile boolean checkedHasChildren;
47 private volatile int childrenCount;
56 checkedHasChildren =
false;
73 if (uniquePath == null) {
75 if (!name.isEmpty()) {
80 if (myParent != null) {
89 if (checkedHasChildren ==
true) {
94 checkedHasChildren =
true;
101 if (childrenCount != -1) {
102 return childrenCount;
107 hasChildren = childrenCount > 0;
108 checkedHasChildren =
true;
110 return childrenCount;
115 if (parent == null) {
116 ObjectInfo parentInfo;
117 parentInfo = db.getParentInfo(
this);
118 if (parentInfo == null) {
127 void setParent(
Content parent) {
128 this.parent = parent;
138 void setParentId(
long parentId) {
157 List<Content> children =
new ArrayList<Content>();
178 List<Long> childrenIDs =
new ArrayList<Long>();
181 childrenIDs.addAll(
getSleuthkitCase().getBlackboardArtifactChildrenIds(
this));
190 if (myParent == null) {
205 return getPool() != null;
215 Volume getPoolVolume() throws TskCoreException {
217 if (myParent == null) {
225 if (myParent instanceof Volume) {
227 if (((Volume) myParent).isPoolContent()) {
228 return (Volume)myParent;
236 return ((AbstractContent)myParent).getPoolVolume();
246 Pool getPool() throws TskCoreException {
248 if (myParent == null) {
252 if (! (myParent instanceof AbstractContent)) {
256 if (myParent instanceof Pool) {
257 return (Pool)myParent;
261 return ((AbstractContent)myParent).getPool();
278 if (getClass() != obj.getClass()) {
282 if (this.objId != other.objId) {
292 }
catch (TskCoreException ex) {
293 Logger.getLogger(AbstractContent.class.getName()).log(Level.SEVERE, null, ex);
301 int hash = 7 + (int) (this.objId ^ (this.objId >>> 32));
304 }
catch (TskCoreException ex) {
305 Logger.getLogger(AbstractContent.class.getName()).log(Level.SEVERE, null, ex);
325 public ArrayList<BlackboardArtifact>
getArtifacts(String artifactTypeName)
throws TskCoreException {
330 public ArrayList<BlackboardArtifact>
getArtifacts(
int artifactTypeID)
throws TskCoreException {
332 if (genInfoArtifact == null)
337 ArrayList<BlackboardArtifact> list =
new ArrayList<BlackboardArtifact>();
339 if (genInfoArtifact != null) {
340 list.add(genInfoArtifact);
359 if (genInfoArtifact != null) {
360 return genInfoArtifact;
366 if (arts.isEmpty()) {
373 retArt = arts.get(0);
375 genInfoArtifact = retArt;
381 ArrayList<BlackboardAttribute> returnList =
new ArrayList<BlackboardAttribute>();
383 if (genInfoArtifact == null) {
385 if (genInfoArtifact == null) {
391 if (attribute.getAttributeType().getTypeID() == attr_type.getTypeID()) {
392 returnList.add(attribute);
426 Set<String> hashNames =
new HashSet<String>();
431 if (attribute != null) {
435 return Collections.unmodifiableSet(hashNames);
445 return "AbstractContent [\t" +
"objId " + String.format(
"%010d", objId) +
"\t"
446 +
"name " + name +
"\t" +
"parentId " + parentId +
"\t"
447 +
"\t" +
"checkedHasChildren " + checkedHasChildren
448 +
"\t" +
"hasChildren " + hasChildren
449 +
"\t" +
"childrenCount " + childrenCount
450 +
"uniquePath " + uniquePath +
"]\t";
454 return "AbstractContent [\t" +
"objId " + String.format(
"%010d", objId)
455 +
"\t" +
"name " + name
456 +
"\t" +
"checkedHasChildren " + checkedHasChildren
457 +
"\t" +
"hasChildren " + hasChildren
458 +
"\t" +
"childrenCount " + childrenCount
462 return "AbstractContent [\t" +
"objId "
463 + String.format(
"%010d", objId) +
"\t" +
"name " + name
464 +
"\t" +
"checkedHasChildren " + checkedHasChildren
465 +
"\t" +
"hasChildren " + hasChildren
466 +
"\t" +
"childrenCount " + childrenCount
468 +
"\t" +
"parentId " + parentId +
"]\t";
470 }
catch (TskCoreException ex) {
471 Logger.getLogger(AbstractContent.class.getName()).log(Level.SEVERE,
"Could not find Parent", ex);
472 return "AbstractContent [\t" +
"objId " + String.format(
"%010d", objId) +
"\t"
473 +
"name " + name +
"\t" +
"parentId " + parentId +
"\t"
474 +
"\t" +
"checkedHasChildren " + checkedHasChildren
475 +
"\t" +
"hasChildren " + hasChildren
476 +
"\t" +
"childrenCount " + childrenCount
477 +
"uniquePath " + uniquePath +
"]\t";
long getBlackboardArtifactsCount(long objId)
synchronized Content getParent()
List< Content > getChildren()
ArrayList< BlackboardArtifact > getBlackboardArtifacts(int artifactTypeID)
ArrayList< BlackboardArtifact > getArtifacts(int artifactTypeID)
Content getContentById(long id)
ArrayList< BlackboardArtifact > getAllArtifacts()
synchronized String getUniquePath()
String toString(boolean preserveState)
ArrayList< BlackboardArtifact > getMatchingArtifacts(String whereClause)
BlackboardArtifact newArtifact(BlackboardArtifact.ARTIFACT_TYPE type)
ArrayList< BlackboardArtifact > getArtifacts(BlackboardArtifact.ARTIFACT_TYPE type)
BlackboardArtifact newBlackboardArtifact(int artifactTypeID, long obj_id)
BlackboardArtifact getGenInfoArtifact()
AbstractContent(SleuthkitCase db, long obj_id, String name)
SleuthkitCase getSleuthkitCase()
boolean equals(Object obj)
BlackboardArtifact.Type getArtifactType(String artTypeName)
long getArtifactsCount(ARTIFACT_TYPE type)
long getAllArtifactsCount()
List< BlackboardAttribute > getAttributes()
BlackboardArtifact newArtifact(int artifactTypeID)
Set< String > getHashSetNames()
long getArtifactsCount(int artifactTypeID)
ArrayList< BlackboardArtifact > getArtifacts(String artifactTypeName)
static final long UNKNOWN_ID
BlackboardArtifact getGenInfoArtifact(boolean create)
ArrayList< BlackboardAttribute > getGenInfoAttributes(ATTRIBUTE_TYPE attr_type)
long getArtifactsCount(String artifactTypeName)
List< Long > getChildrenIds()