Check the type of a field


public int checkFieldType(Document doc, String fieldName) throws NotesException {
    if (doc.hasItem(fieldName)) {
        Item item = doc.getFirstItem(fieldName);
        String type;
        switch (item.getType()) {
            case Item.ACTIONCD:
                type = "Action CD (16)";
                break;
            case Item.ASSISTANTINFO:
                type = "Assistant information (17)";
                break;
            case Item.ATTACHMENT:
                type = "File attachment (1084)";
                break;
            case Item.AUTHORS:
                type = "Authors (1076)";
                break;
            case Item.COLLATION:
                type = "Collation (2)";
                break;
            case Item.DATETIMES:
                type = "Date-time or range of date-times (1024)";
                break;
            case Item.EMBEDDEDOBJECT:
                type = "Embedded object (1090)";
                break;
            case Item.ERRORITEM:
                type = "Error while accessing type (256)";
                break;
            case Item.FORMULA:
                type = "Formula (1536)";
                break;
            case Item.HTML:
                type = "HTML source text (21)";
                break;
            case Item.ICON:
                type = "Icon (6)";
                break;
            case Item.LSOBJECT:
                type = "LotusScript object (20)";
                break;
            case Item.NAMES:
                type = "Names (1074)";
                break;
            case Item.NOTELINKS:
                type = "Link to database, view, or document (7)";
                break;
            case Item.NOTEREFS:
                type = "Reference to the parent document (4)";
                break;
            case Item.NUMBERS:
                type = "Number or number list (768)";
                break;
            case Item.OTHEROBJECT:
                type = "Other object (1085)";
                break;
            case Item.QUERYCD:
                type = "Query CD (15)";
                break;
            case Item.RICHTEXT:
                type = "Rich text (1)";
                break;
            case Item.READERS:
                type = "Readers (1075)";
                break;
            case Item.SIGNATURE:
                type = "Signature (8)";
                break;
            case Item.TEXT:
                type = "Text or text list (1280)";
                break;
            case Item.UNAVAILABLE:
                type = "Unavailable type (512)";
                break;
            case Item.UNKNOWN:
                type = "Unknown typet (0)";
                break;
            case Item.USERDATA:
                type = "User data (14)";
                break;
            case Item.USERID:
                type = "User ID name (1792)";
                break;
            case Item.VIEWMAPDATA:
                type = "View map data (18)";
                break;
            case Item.VIEWMAPLAYOUT:
                type = "View map layout (19)";
                break;
            default:
                type = "Other";
        }
        return item.getType();
    } else {
        return -1;
    }
}
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
No comments yetLogin first to comment...