public Attribute get(String name, boolean caseSensitive) {
   AttributeRole result = findRoleByName(name, caseSensitive);
   if (result == null) {
     result = findRoleBySpecialName(name, caseSensitive);
   }
   if (result != null) {
     return result.getAttribute();
   } else {
     return null;
   }
 }
  public void clearRegular() {
    List<AttributeRole> toRemove = new LinkedList<AttributeRole>();
    Iterator<AttributeRole> i = allAttributeRoles();
    while (i.hasNext()) {
      AttributeRole role = i.next();
      if (!role.isSpecial()) toRemove.add(role);
    }

    for (AttributeRole role : toRemove) {
      remove(role);
    }
  }
 public void setSpecialAttribute(Attribute attribute, String specialName) {
   AttributeRole oldRole = findRoleBySpecialName(specialName);
   if (oldRole != null) {
     remove(oldRole);
   }
   if (attribute != null) {
     remove(attribute);
     AttributeRole role = new AttributeRole(attribute);
     role.setSpecial(specialName);
     ;
     add(role);
   }
 }
 public Attribute replace(Attribute first, Attribute second) {
   AttributeRole role = getRole(first);
   if (role != null) {
     role.setAttribute(second);
   } else {
     throw new java.util.NoSuchElementException(
         "Attribute "
             + first
             + " cannot be replaced by attribute "
             + second
             + ": "
             + first
             + " is not part of the example set!");
   }
   return second;
 }
Exemplo n.º 5
0
 public boolean hasNext() {
   while ((current == null) && (parent.hasNext())) {
     AttributeRole candidate = parent.next();
     switch (type) {
       case Attributes.REGULAR:
         if (!candidate.isSpecial()) current = candidate;
         break;
       case Attributes.SPECIAL:
         if (candidate.isSpecial()) current = candidate;
         break;
       case Attributes.ALL:
         current = candidate;
         break;
       default:
         break;
     }
   }
   return current != null;
 }
 public Attribute getRegular(String name) {
   AttributeRole role = findRoleByName(name);
   if (role != null) {
     if (!role.isSpecial()) {
       return role.getAttribute();
     } else {
       // LogService.getGlobal().logWarning("No regular attribute with name '"+name+"' found,
       // however, there is a special attribute with the same name.");
       LogService.getRoot()
           .log(
               Level.WARNING,
               "com.rapidminer.example.AbstractAttributes.no_regular_attribute_found",
               name);
       return null;
     }
   } else {
     return null;
   }
   // return findAttribute(name, iterator());
 }
 public Attribute getSpecial(String name) {
   AttributeRole role = findRoleBySpecialName(name);
   if (role == null) return null;
   else return role.getAttribute();
 }