code: private void setupSubjects(List<Subject> subjects) throws ParsingException {
          // make sure that there is at least one Subject
          if (subjects.size() == 0)
              throw new ParsingException("Request must a contain subject");
  
          // now go through the subject attributes
          Iterator<Subject> it = subjects.iterator();
          while (it.hasNext()) {
              Subject subject = it.next();
  
              URI category = subject.getCategory();
              Map<String, List<Attribute>> categoryMap = null;
  
              // see if we've already got a map for the category
              if (subjectMap.containsKey(category)) {
                  categoryMap = subjectMap.get(category);
              } else {
                  categoryMap = new HashMap<String, List<Attribute>>();
                  subjectMap.put(category, categoryMap);
              }
  
              // iterate over the set of attributes
              Iterator attrIterator = subject.getAttributesAsList().iterator();
  
              while (attrIterator.hasNext()) {
                  Attribute attr = (Attribute)(attrIterator.next());
                  String id = attr.getId().toString();
  
                  if (categoryMap.containsKey(id)) {
                      // add to the existing set of Attributes w/this id
                      List existingIds = (List)(categoryMap.get(id));
                      existingIds.add(attr);
                  } else {
                      // this is the first Attr w/this id
                      List newIds = new ArrayList();
                      newIds.add(attr);
                      categoryMap.put(id, newIds);
                  }
              }
          }
      }
docs: This is quick helper function to provide a little structure for the
  subject attributes so we can search for them (somewhat) quickly. The
  basic idea is to have a map indexed by SubjectCategory that keeps
  Maps that in turn are indexed by id and keep the unique ctx.Attribute
  objects.