diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/ChunkResult.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/ChunkResult.java new file mode 100644 index 000000000..23145c327 --- /dev/null +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/ChunkResult.java @@ -0,0 +1,64 @@ +/* + * Copyright 2006-2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.batch.core.domain; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.core.enums.ShortCodedLabeledEnum; + +/** + * + * @author Ben Hale + */ +public class ChunkResult { + + public static final ChunkResultType SUCCESS = new ChunkResultType(0, "Success"); + + public static final ChunkResultType FAILURE = new ChunkResultType(1, "Failure"); + + private final ChunkResultType resultType; + + private final Long chunkId; + + private final List skippedItems; + + public ChunkResult(ChunkResultType resultType, Long chunkId, List skippedItems) { + this.resultType = resultType; + this.chunkId = chunkId; + this.skippedItems = skippedItems; + } + + public ChunkResultType getResultType() { + return resultType; + } + + public Long getChunkId() { + return chunkId; + } + + public List getSkippedItems() { + return new ArrayList(skippedItems); + } + + private static class ChunkResultType extends ShortCodedLabeledEnum { + + public ChunkResultType(int code, String label) { + super(code, label); + } + + } +} diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Dechunker.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Dechunker.java new file mode 100644 index 000000000..2680bc6c1 --- /dev/null +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Dechunker.java @@ -0,0 +1,33 @@ +/* + * Copyright 2006-2008 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.batch.core.domain; + +import org.springframework.batch.item.ItemReader; + +/** + * Interface defining the contract for dechunking a {@link Chunk}. Similar + * to the differences between an {@link ItemReader} and an {@link ItemWriter}, + * a dechunker is the polar oposite of a {@link Chunker}. A {@link Chunker} creates + * a chunk from a stream of items, wheras a Dechunker removes each item from the + * {@link Chunk} and adds it to an outgoing stream of items. + * + * @author Lucas Ward + * + */ +public interface Dechunker { + + ChunkResult dechunk(Chunk chunk) throws Exception; +} diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/ReadFailurePolicy.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/ItemSkipPolicy.java similarity index 87% rename from spring-batch-core/src/main/java/org/springframework/batch/core/domain/ReadFailurePolicy.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/domain/ItemSkipPolicy.java index 19ab021a4..36698d16b 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/ReadFailurePolicy.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/ItemSkipPolicy.java @@ -18,11 +18,11 @@ package org.springframework.batch.core.domain; import org.springframework.batch.core.domain.StepExecution; /** - * Policy for determining whether or not reading should continue. + * Policy for determining whether or not an item should be skipped. * * @author Lucas Ward */ -public interface ReadFailurePolicy { +public interface ItemSkipPolicy { /** * Returns true or false, indicating whether or not reading should @@ -33,5 +33,5 @@ public interface ReadFailurePolicy { * @return true if reading should continue, false otherwise. * @throws IllegalArgumentException if t or stepExecution is null */ - boolean shouldContinue(Exception ex, StepExecution stepExecution); + boolean shouldSkip(Exception ex, StepExecution stepExecution); }