Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FormField#getKind (fixes #390) #391

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
* @author Karsten Lehmann
*/
public interface FormField {
public enum Kind {
COMPUTED, COMPUTEDFORDISPLAY, COMPUTEDWHENCOMPOSED, EDITABLE
}

/**
* Returns the field data type
Expand Down Expand Up @@ -145,8 +148,15 @@ public interface FormField {
* If the field is a static textlist, this method returns the text list values
*
* @return an {@link Optional} describing the text list values, or an empty one
* if that
* does not apply
* if that does not apply
*/
Optional<List<String>> getTextListValues();

/**
* Determines the editability/computed kind of the field
*
* @return a {@link Kind} value for the field
* @since 1.27.0
*/
Kind getKind();
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.hcl.domino.design.format.FieldListDelimiter;
import com.hcl.domino.design.format.FieldListDisplayDelimiter;
import com.hcl.domino.formula.FormulaCompiler;
import com.hcl.domino.misc.INumberEnum;
import com.hcl.domino.misc.StructureSupport;
import com.hcl.domino.richtext.RichTextConstants;
import com.hcl.domino.richtext.annotation.StructureDefinition;
Expand Down Expand Up @@ -61,62 +60,8 @@
@StructureMember(name = "DescLength", type = short.class, unsigned = true),
@StructureMember(name = "TextValueLength", type = short.class, unsigned = true),
})
public interface CDField extends RichTextRecord<WSIG> {
enum Flag implements INumberEnum<Short> {
/** Field contains read/writers */
READWRITERS(RichTextConstants.FREADWRITERS),
/** Field is editable, not read only */
EDITABLE(RichTextConstants.FEDITABLE),
/** Field contains distinguished names */
NAMES(RichTextConstants.FNAMES),
/** Store DV, even if not spec'ed by user */
STOREDV(RichTextConstants.FSTOREDV),
/** Field contains document readers */
READERS(RichTextConstants.FREADERS),
/** Field contains a section */
SECTION(RichTextConstants.FSECTION),
/** can be assumed to be clear in memory, V3 &amp; later */
SPARE3(RichTextConstants.FSPARE3),
/** IF CLEAR, CLEAR AS ABOVE */
V3FAB(RichTextConstants.FV3FAB),
/** Field is a computed field */
COMPUTED(RichTextConstants.FCOMPUTED),
/** Field is a keywords field */
KEYWORDS(RichTextConstants.FKEYWORDS),
/** Field is protected */
PROTECTED(RichTextConstants.FPROTECTED),
/** Field name is simply a reference to a shared field note */
REFERENCE(RichTextConstants.FREFERENCE),
/** sign field */
SIGN(RichTextConstants.FSIGN),
/** seal field */
SEAL(RichTextConstants.FSEAL),
/** standard UI */
KEYWORDS_UI_STANDARD(RichTextConstants.FKEYWORDS_UI_STANDARD),
/** checkbox UI */
KEYWORDS_UI_CHECKBOX(RichTextConstants.FKEYWORDS_UI_CHECKBOX),
/** radiobutton UI */
KEYWORDS_UI_RADIOBUTTON(RichTextConstants.FKEYWORDS_UI_RADIOBUTTON),
/** allow doc editor to add new values */
KEYWORDS_UI_ALLOW_NEW(RichTextConstants.FKEYWORDS_UI_ALLOW_NEW);

private final short value;

Flag(final short value) {
this.value = value;
}

@Override
public long getLongValue() {
return this.value;
}

@Override
public Short getValue() {
return this.value;
}
}

public interface CDField extends RichTextRecord<WSIG>, ICDField {
@Override
default String getDefaultValueFormula() {
return StructureSupport.extractCompiledFormula(
this,
Expand All @@ -127,6 +72,7 @@ default String getDefaultValueFormula() {
@StructureGetter("DVLength")
int getDefaultValueLength();

@Override
default String getDescription() {
return StructureSupport.extractStringValue(
this,
Expand All @@ -138,6 +84,7 @@ default String getDescription() {
int getDescriptionLength();

@StructureGetter("DataType")
@Override
Optional<ItemDataType> getFieldType();

/**
Expand All @@ -150,6 +97,7 @@ default String getDescription() {
short getFieldTypeRaw();

@StructureGetter("Flags")
@Override
Set<Flag> getFlags();

@StructureGetter("FontID")
Expand All @@ -159,6 +107,7 @@ default String getDescription() {
@Override
WSIG getHeader();

@Override
default String getInputTranslationFormula() {
return StructureSupport.extractCompiledFormula(
this,
Expand All @@ -169,6 +118,7 @@ default String getInputTranslationFormula() {
@StructureGetter("ITLength")
int getInputTranslationLength();

@Override
default String getInputValidationFormula() {
return StructureSupport.extractCompiledFormula(
this,
Expand All @@ -183,8 +133,10 @@ default String getInputValidationFormula() {
short getListDelimiterRaw();

@StructureGetter("ListDelim")
@Override
Set<FieldListDelimiter> getListDelimiters();

@Override
default FieldListDisplayDelimiter getListDisplayDelimiter() {
// The default mechanism doesn't pick up this single value, since the storage is
// masked with
Expand All @@ -198,6 +150,7 @@ default FieldListDisplayDelimiter getListDisplayDelimiter() {
return null;
}

@Override
default String getName() {
return StructureSupport.extractStringValue(
this,
Expand All @@ -214,10 +167,7 @@ default String getName() {
@StructureGetter("TabOrder")
int getTabOrder();

/**
* @return an {@link Optional} describing the value formula for field choices,
* or an empty one if the values are defined by a an explicit text list
*/
@Override
default Optional<String> getTextValueFormula() {
final int len = this.getTextValueLength();
if (len == 0) {
Expand All @@ -242,11 +192,7 @@ default Optional<String> getTextValueFormula() {
@StructureGetter("TextValueLength")
int getTextValueLength();

/**
* @return an {@link Optional} describing the explicit text value options for
* this field,
* or an empty one if the values are defined by a formula
*/
@Override
default Optional<List<String>> getTextValues() {
final int len = this.getTextValueLength();
if (len == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.hcl.domino.design.format.FieldListDelimiter;
import com.hcl.domino.design.format.FieldListDisplayDelimiter;
import com.hcl.domino.formula.FormulaCompiler;
import com.hcl.domino.misc.INumberEnum;
import com.hcl.domino.misc.StructureSupport;
import com.hcl.domino.richtext.RichTextConstants;
import com.hcl.domino.richtext.annotation.StructureDefinition;
Expand Down Expand Up @@ -64,62 +63,9 @@
@StructureMember(name = "DescLength", type = short.class, unsigned = true)
}
)
public interface CDFieldPre36 extends RichTextRecord<WSIG> {
enum Flag implements INumberEnum<Short> {
/** Field contains read/writers */
READWRITERS(RichTextConstants.FREADWRITERS),
/** Field is editable, not read only */
EDITABLE(RichTextConstants.FEDITABLE),
/** Field contains distinguished names */
NAMES(RichTextConstants.FNAMES),
/** Store DV, even if not spec'ed by user */
STOREDV(RichTextConstants.FSTOREDV),
/** Field contains document readers */
READERS(RichTextConstants.FREADERS),
/** Field contains a section */
SECTION(RichTextConstants.FSECTION),
/** can be assumed to be clear in memory, V3 &amp; later */
SPARE3(RichTextConstants.FSPARE3),
/** IF CLEAR, CLEAR AS ABOVE */
V3FAB(RichTextConstants.FV3FAB),
/** Field is a computed field */
COMPUTED(RichTextConstants.FCOMPUTED),
/** Field is a keywords field */
KEYWORDS(RichTextConstants.FKEYWORDS),
/** Field is protected */
PROTECTED(RichTextConstants.FPROTECTED),
/** Field name is simply a reference to a shared field note */
REFERENCE(RichTextConstants.FREFERENCE),
/** sign field */
SIGN(RichTextConstants.FSIGN),
/** seal field */
SEAL(RichTextConstants.FSEAL),
/** standard UI */
KEYWORDS_UI_STANDARD(RichTextConstants.FKEYWORDS_UI_STANDARD),
/** checkbox UI */
KEYWORDS_UI_CHECKBOX(RichTextConstants.FKEYWORDS_UI_CHECKBOX),
/** radiobutton UI */
KEYWORDS_UI_RADIOBUTTON(RichTextConstants.FKEYWORDS_UI_RADIOBUTTON),
/** allow doc editor to add new values */
KEYWORDS_UI_ALLOW_NEW(RichTextConstants.FKEYWORDS_UI_ALLOW_NEW);

private final short value;

Flag(final short value) {
this.value = value;
}

@Override
public long getLongValue() {
return this.value;
}

@Override
public Short getValue() {
return this.value;
}
}
public interface CDFieldPre36 extends RichTextRecord<WSIG>, ICDField {

@Override
default String getDefaultValueFormula() {
return StructureSupport.extractCompiledFormula(
this,
Expand All @@ -130,6 +76,7 @@ default String getDefaultValueFormula() {
@StructureGetter("DVLength")
int getDefaultValueLength();

@Override
default String getDescription() {
return StructureSupport.extractStringValue(
this,
Expand All @@ -141,6 +88,7 @@ default String getDescription() {
int getDescriptionLength();

@StructureGetter("DataType")
@Override
Optional<ItemDataType> getFieldType();

/**
Expand All @@ -153,6 +101,7 @@ default String getDescription() {
short getFieldTypeRaw();

@StructureGetter("Flags")
@Override
Set<Flag> getFlags();

@StructureGetter("FontID")
Expand All @@ -162,6 +111,7 @@ default String getDescription() {
@Override
WSIG getHeader();

@Override
default String getInputTranslationFormula() {
return StructureSupport.extractCompiledFormula(
this,
Expand All @@ -172,6 +122,7 @@ default String getInputTranslationFormula() {
@StructureGetter("ITLength")
int getInputTranslationLength();

@Override
default String getInputValidationFormula() {
return StructureSupport.extractCompiledFormula(
this,
Expand All @@ -186,8 +137,10 @@ default String getInputValidationFormula() {
short getListDelimiterRaw();

@StructureGetter("ListDelim")
@Override
Set<FieldListDelimiter> getListDelimiters();

@Override
default FieldListDisplayDelimiter getListDisplayDelimiter() {
// The default mechanism doesn't pick up this single value, since the storage is
// masked with
Expand All @@ -201,6 +154,7 @@ default FieldListDisplayDelimiter getListDisplayDelimiter() {
return null;
}

@Override
default String getName() {
return StructureSupport.extractStringValue(
this,
Expand All @@ -214,10 +168,7 @@ default String getName() {
@StructureGetter("NumberFormat")
NFMT getNumberFormat();

/**
* @return an {@link Optional} describing the value formula for field choices,
* or an empty one if the values are defined by a an explicit text list
*/
@Override
default Optional<String> getTextValueFormula() {
final int len = this.getTextValueLength();
if (len == 0) {
Expand Down Expand Up @@ -245,11 +196,7 @@ default int getTextValueLength() {
- getNameLength() - getDescriptionLength();
}

/**
* @return an {@link Optional} describing the explicit text value options for
* this field,
* or an empty one if the values are defined by a formula
*/
@Override
default Optional<List<String>> getTextValues() {
final int len = this.getTextValueLength();
if (len == 0) {
Expand Down
Loading
Loading