示例#1
0
  public void read() throws IOException {
    //
    byte[] data = segment.getData();
    int count = 0;

    byte numOfComponents = data[count++];
    Component[] components = reader.getComponents();

    for (int i = 0; i < numOfComponents; i++) {
      byte id = data[count++];
      byte tbl_no = data[count++];

      for (Component component : components) {
        if (component.getId() == id) {
          component.setACTableNumber((byte) (tbl_no & 0x0f));
          component.setDCTableNumber((byte) ((tbl_no >> 4) & 0x0f));
          break;
        }
      }
    }

    // Start of spectral or predictor selection
    Ss = data[count++];
    // End of spectral selection
    Se = data[count++];
    // Ah: Successive approximation bit position high
    // Al: Successive approximation bit position low or point transform
    Ah_Al = data[count++];
    Ah = (Ah_Al >> 4) & 0x0f;
    Al = Ah_Al & 0x0f;
  }
示例#2
0
 static String componentFileName(Component component) {
   return String.format("%05x", component.getId())
       + "_"
       + component.getData().replace(' ', '_').replace('/', '_')
       + "_"
       + CKType.resolve(component.getComponentType());
 }
示例#3
0
  // @Test
  public void select() {
    ConvertUtilsExtend.init();
    Connection c = DbOper.getConn();

    try {
      Statement st = c.createStatement();

      ResultSet rs = st.executeQuery("select * from t_user");
      ResultSetMetaData rsmd = rs.getMetaData();
      List<String> tableColumnNames = new ArrayList<String>();
      for (int i = 0; i < rsmd.getColumnCount(); i++) {
        tableColumnNames.add(rsmd.getColumnName(i + 1));
      }
      Class<?> clazz = Component.class;
      List<Component> datas = new ArrayList<Component>();

      if (rs != null) {
        while (rs.next()) {
          Object object = clazz.newInstance();
          for (String columnName : tableColumnNames) {
            BeanUtils.setProperty(object, columnName.toLowerCase(), rs.getObject(columnName));
          }
          datas.add((Component) object);
        }
      }
      for (Component ct : datas) {
        System.out.println(ct.getId() + "  " + ct.getCaption());
      }
      st.close();
      DbOper.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
示例#4
0
  @Override
  public RequestStatus updateComponent(Component component, User user) throws TException {
    assertNotNull(component);
    assertId(component.getId());
    assertUser(user);

    return handler.updateComponent(component, user);
  }
示例#5
0
  @Override
  public AddDocumentRequestSummary addComponent(Component component, User user) throws TException {
    assertNotNull(component);
    assertIdUnset(component.getId());
    assertUser(user);

    return handler.addComponent(component, user.getEmail());
  }
 /** Make sure components are iterated in the order they were added. Required e.g. for Repeaters */
 @Test
 public void iteratorOrder() {
   MarkupContainer container = new WebMarkupContainer("component");
   for (int i = 0; i < 10; i++) {
     container.add(new WebComponent(Integer.toString(i)));
   }
   int i = 0;
   for (Component component : container) {
     assertEquals(Integer.toString(i++), component.getId());
   }
 }
示例#7
0
  /**
   * Converts a component to a path (relavant to another component). It is usefully to implement a
   * serializable component that contains a reference to another component. In this case, we can not
   * serializes the reference directly (otherwise, another component will be created, when
   * deserialized).
   *
   * <p>Rather, it is better to store the path related, and then restore it back to a component by
   * calling {@link #pathToComponent}.
   *
   * @param comp the component to be converted to path. It cannot be null.
   * @param ref the component used to generated the path from. It cannot be null.
   * @return the path. Notice that you have to use {@link #pathToComponent} to convert it back.
   * @exception UnsupportedOperationException if we cannot find a path to the component to write.
   * @since 3.0.0
   */
  public static final String componentToPath(Component comp, Component ref) {
    // Implementation Note:
    // The path being written is a bit different to Path, if ref
    // is not an space owner
    // For example, if comp is the space owner, "" is written.
    // If comp is the same as ref, "." is written.
    if (comp == null) {
      return null;
    } else if (comp == ref) {
      return ".";
    } else {
      final String id = comp.getId();
      if (!(comp instanceof IdSpace) && id.length() == 0)
        throw new UnsupportedOperationException(
            "comp must be assigned with ID or a space owner: " + comp);

      final StringBuffer sb = new StringBuffer(128);
      for (IdSpace space = ref.getSpaceOwner(); ; ) {
        if (comp == space) {
          return sb.toString(); // could be ""
          // we don't generate id to make it work even if
          // its ID is changed
        } else if (space.getFellowIfAny(id) == comp) {
          if (sb.length() > 0) sb.append('/');
          return sb.append(id).toString();
        }

        if (sb.length() > 0) sb.append('/');
        sb.append("..");

        final Component parent =
            space instanceof Component ? ((Component) space).getParent() : null;
        if (parent == null)
          throw new UnsupportedOperationException("Unable to locate " + comp + " from " + ref);
        space = parent.getSpaceOwner();
      }
    }
  }
示例#8
0
 /**
  * Unregisters a component. Should never need to be called directly.
  *
  * @param component the component to unregister
  */
 void unregister(Component component) {
   map.remove(component.getId());
   fireEvent(Events.Unregister, new ComponentManagerEvent(this, component));
 }
示例#9
0
 /**
  * Registers a component. Should never need to be called directly.
  *
  * @param component the component to register
  */
 void register(Component component) {
   map.put(component.getId(), component);
   fireEvent(Events.Register, new ComponentManagerEvent(this, component));
 }