00001 package edu.tum.cs.srldb.datadict; 00002 00003 import java.io.PrintStream; 00004 import java.io.Serializable; 00005 00006 import edu.tum.cs.srldb.IdentifierNamer; 00007 import edu.tum.cs.srldb.Database; 00008 import edu.tum.cs.util.StringTool; 00009 00010 public class DDObject extends DDItem implements IDDRelationArgument, Serializable { 00011 private static final long serialVersionUID = 1L; 00012 00016 public DDObject(String name) { 00017 super(name); 00018 } 00019 00020 public boolean isObject() { 00021 return true; 00022 } 00023 00024 public void MLNprintPredicateDeclarations(IdentifierNamer idNamer, PrintStream out) { 00025 out.println("// " + this.getName()); 00026 String objectDomain = idNamer.getLongIdentifier("domain", Database.stdDomainName(this.getName())); 00027 for(DDAttribute attr : attributes.values()) { 00028 MLNprintAttributePredicateDeclaration(attr, objectDomain, idNamer, out); 00029 } 00030 out.println(); 00031 } 00032 00033 public void BLNprintPredicateDeclarations(IdentifierNamer idNamer, PrintStream out) { 00034 out.println("// " + this.getName()); 00035 String objectDomain = idNamer.getLongIdentifier("domain", Database.stdDomainName(this.getName())); 00036 for(DDAttribute attr : attributes.values()) { 00037 BLNprintAttributePredicateDeclaration(attr, objectDomain, idNamer, out); 00038 } 00039 out.println(); 00040 } 00041 00042 @Deprecated 00043 public void MLNprintRules(IdentifierNamer idNamer, PrintStream out) { 00044 out.println("// mutual exclusiveness and exhaustiveness: " + getName() + " attributes"); 00045 for(DDAttribute attr : attributes.values()) { 00046 if(attr.isDiscarded() || attr.isBoolean()) 00047 continue; 00048 idNamer.resetCounts(); 00049 out.print(Database.stdPredicateName(attr.getName()) + "(" + idNamer.getCountedShortIdentifier("var", this.getName())); 00050 out.print(", "); 00051 out.println(idNamer.getCountedShortIdentifier("var", attr.getDomain().getName()) + "!)"); 00052 } 00053 } 00054 00055 public String getDomainName() { 00056 return name; 00057 } 00058 00059 public String toString() { 00060 return String.format("DDObject:%s [%s]", name, StringTool.join(", ", this.attributes.values())); 00061 } 00062 }