Package org.xorm.util

Examples of org.xorm.util.FieldDescriptor


                Class[] fieldTypes = new Class[len];
                byte[] fieldFlags = new byte[len];
                int i = 0;
                Iterator it = managedFields.iterator();
                while (it.hasNext()) {
                    FieldDescriptor fd = mapping.getFieldDescriptor
                        ((String) it.next());
                    fieldNames[i] = fd.name;
                    fieldTypes[i] = fd.type;
                    fieldFlags[i] = (byte) (pc.CHECK_READ | pc.CHECK_WRITE);
                    i++;
View Full Code Here


     * in the row when newly created.
     */
    private void initDefaultValues() {
        Iterator i = mapping.getMappedFieldDescriptors().iterator();
        while (i.hasNext()) {
            FieldDescriptor fd =
                (FieldDescriptor) i.next();
            Column c = mapping.getColumn(fd.name);
            if (!c.isReadOnly()) {
                row.setValue(c, fd.type.isPrimitive() ?
                             defaultValue(fd.type) : null);
View Full Code Here

            // Handle a field of a field of a field of a...
            Class currentClass = getCandidateClass();
            StringTokenizer tok = new StringTokenizer(field, ".");

            String fieldToken;
      FieldDescriptor fd;
      Selector firstSelector = null, currentSelector = null;
     
      while (modelMapping.isManagedType(currentClass)) {
    ClassMapping currentClassMapping = modelMapping.getClassMapping(currentClass);
   
View Full Code Here

        //classElem.setAttribute("identity-type", "datastore");
       
        ArrayList fds = new ArrayList(FieldDescriptor.getFieldDescriptors(clazz));
                    Collections.sort(fds, new Comparator() {
                            public int compare(Object obj1, Object obj2) {
                                FieldDescriptor fd1 = (FieldDescriptor)obj1;
                                FieldDescriptor fd2 = (FieldDescriptor)obj1;
                                return fd1.name.compareTo(fd2.name);
                            }
                        });
                   
        for (Iterator j = fds.iterator(); j.hasNext(); ) {
      FieldDescriptor fd = (FieldDescriptor) j.next();
      Element field = new Element("field");
      field.setAttribute("name", fd.name);
      Class pdType = fd.type;
      if (pdType.isArray()) {
          // TODO handling for array
View Full Code Here

            JDOImplHelper helper = JDOImplHelper.getInstance();
            String[] names = helper.getFieldNames(clazz);
            Class[] types = helper.getFieldTypes(clazz);
            fields = new ArrayList();
            for (int i = 0; i < names.length; i++) {
                fields.add(new FieldDescriptor(names[i], types[i]));
            }
        }
        init();
    }
View Full Code Here

     */
    private void init(){
        defaultFetchGroup = new DataFetchGroup();
        Iterator i = fields.iterator();
        while (i.hasNext()) {
            FieldDescriptor fd = (FieldDescriptor) i.next();
            // This is a kluge for now, maybe require explicit config on this?
            if (isUserType(fd.type)) {
                RelationshipMapping implicit = new RelationshipMapping();
                RelationshipMapping.Endpoint end1 = new RelationshipMapping.Endpoint();
   
View Full Code Here

            pk = new Column(table, "xorm_pk");
            table.addColumn(pk);
            table.setPrimaryKey(pk);
            Iterator i = fields.iterator();
            while (i.hasNext()) {
                FieldDescriptor fd = (FieldDescriptor) i.next();
                Column c = new Column(table, fd.name);
                table.addColumn(c);
                fieldToColumn.put(fd.name, c);
            }
        } else {
View Full Code Here

     * Retrieves the field associated with a get or set method.
     * Returns null if there is no mapping.
     */
    public String getFieldForMethod(Method method) {
        String methodName = method.getName();
        FieldDescriptor fd = (FieldDescriptor) methodToProperty.get(methodName);
        if (fd == null) return null;
        return fd.name;
    }
View Full Code Here

     *
     * @exception JDOUserException if the field does not exist, or if
     * the field has a set() method but the column is marked as read-only.
     */
    public void setColumn(String field, Column column, Boolean inDefaultFetchGroup) {
        FieldDescriptor fd = getFieldDescriptor(field);
        if (column.isReadOnly() && (fd.writeMethod != null)) {
            throw new JDOUserException(I18N.msg("E_setter_ro_column", new Object[] {
                column.getName(), clazz.getName(), field }));
        }
        mappedFields.add(fd);
View Full Code Here

     * Define a to-many relationship on a field.
     *
     * @exception JDOUserException if the field does not exist
     */
    public void setRelationship(String field, RelationshipMapping relation) {
        FieldDescriptor fd = getFieldDescriptor(field); // assertion
        relationships.put(field, relation);
        managedFields.add(field);
    }
View Full Code Here

TOP

Related Classes of org.xorm.util.FieldDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.