コード例 #1
0
  public net.sf.ahtutils.xml.security.Category build(C category) {
    Category xml = new Category();
    if (q.isSetCode()) {
      xml.setCode(category.getCode());
    }
    if (q.isSetPosition()) {
      xml.setPosition(category.getPosition());
    }
    if (q.isSetVisible()) {
      xml.setVisible(category.isVisible());
    }
    if (q.isSetDocumentation() && category.getDocumentation() != null) {
      xml.setDocumentation(category.getDocumentation());
    }

    if (q.isSetLangs()) {
      XmlLangsFactory<L> f = new XmlLangsFactory<L>(q.getLangs());
      xml.setLangs(f.getUtilsLangs(category.getName()));
    }

    if (q.isSetDescriptions()) {
      XmlDescriptionsFactory<D> f = new XmlDescriptionsFactory<D>(q.getDescriptions());
      xml.setDescriptions(f.create(category.getDescription()));
    }

    if (q.isSetLabel() && lang != null) {
      if (category.getName() != null) {
        if (category.getName().containsKey(lang)) {
          xml.setLabel(category.getName().get(lang).getLang());
        } else {
          String msg = "No translation " + lang + " available in " + category;
          logger.warn(msg);
          xml.setLabel(msg);
        }
      } else {
        String msg = "No @name available in " + category;
        logger.warn(msg);
        xml.setLabel(msg);
      }
    }

    return xml;
  }
コード例 #2
0
  public void moveCursorOrThrow(int position)
      throws IndexOutOfBoundsException, IllegalStateException {

    if (position >= getItemCount() || position < -1) {
      throw new IndexOutOfBoundsException(
          "Position: " + position + " is invalid for this data set!");
    }

    if (!mDataValid) {
      throw new IllegalStateException("Attempt to move cursor over invalid data set!");
    }

    if (!mCursor.moveToPosition(position)) {
      throw new IllegalStateException(
          "Couldn't move cursor from position: "
              + mCursor.getPosition()
              + " to position: "
              + position
              + "!");
    }
  }