01: /**
02: * Objective Database Abstraction Layer (ODAL)
03: * Copyright (c) 2004, The ODAL Development Group
04: * All rights reserved.
05: * For definition of the ODAL Development Group please refer to LICENCE.txt file
06: *
07: * Distributable under LGPL license.
08: * See terms of license at gnu.org.
09: */package com.completex.objective.components.persistency.rule.impl;
10:
11: import com.completex.objective.components.persistency.PersistentEntry;
12: import com.completex.objective.components.persistency.rule.RuleException;
13:
14: /**
15: * @author Gennady Krizhevsky
16: */
17: public class TrimRightFieldConvertor extends AbstractFieldConvertor {
18:
19: private int targetSize;
20:
21: public TrimRightFieldConvertor(int targetSize) {
22: this .targetSize = targetSize;
23: }
24:
25: public void convert(PersistentEntry entry) throws RuleException {
26: // RuleHelper.assertRecordAndIndex(entry, fieldIndex);
27: if (!entry.isDirty() || targetSize < 0) {
28: return;
29: }
30:
31: String value = entry.getString();
32: if (value == null || value.length() < targetSize) {
33: return;
34: }
35:
36: setValue(entry, value.substring(0, targetSize));
37: }
38:
39: }
|