2 * Copyright (c) 2018-2020. Developed by Hedgecode.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.hedgecode.chess.pgn.format.wrap;
19 import static org.hedgecode.chess.pgn.PGNConstants.*;
24 * @author Dmitry Samoshin aka gotty
26 public abstract class AbstractWrapper implements MovesWrapper {
28 protected abstract int length();
31 public String wrap(String moves) {
32 StringBuilder sb = new StringBuilder();
33 int startIndex = 0, endIndex = 0;
34 moves = moves.concat(PGN_SPACE);
35 int index = moves.indexOf(PGN_SPACE);
37 if (index - startIndex >= length()) {
39 moves.substring(startIndex, endIndex)
41 startIndex = endIndex + 1;
44 index = moves.indexOf(PGN_SPACE, index + 1);
47 moves.substring(startIndex)