diff --git a/.gitignore b/.gitignore index 149242e9..ad2d8752 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ target/ /*.iws out .gradletasknamecache +.DS_Store diff --git a/src/main/java/org/springframework/shell/TerminalSizeAware.java b/src/main/java/org/springframework/shell/TerminalSizeAware.java index a9fa6d77..00bf20db 100644 --- a/src/main/java/org/springframework/shell/TerminalSizeAware.java +++ b/src/main/java/org/springframework/shell/TerminalSizeAware.java @@ -1,9 +1,25 @@ +/* + * Copyright 2017 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.shell; /** * To be implemented by command result objects that can adapt to the terminal size when they are being rendered. * - *
An object which does not implement this interface will simply be rendered by invoking its {@link #toString()} + *
An object which does not implement this interface will simply be rendered by invoking its {@link Object#toString()} * method.
* * @author Eric Bottard diff --git a/src/main/java/org/springframework/shell/table/Aligner.java b/src/main/java/org/springframework/shell/table/Aligner.java index 23ac5ce0..e81bc547 100644 --- a/src/main/java/org/springframework/shell/table/Aligner.java +++ b/src/main/java/org/springframework/shell/table/Aligner.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2017 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. @@ -24,11 +24,18 @@ package org.springframework.shell.table; public interface Aligner { /** - * Perform text alignment, returning a String array that MUST contain - * {@code cellHeight} lines, each of which MUST be {@code cellWidth} chars in length. + * Perform text alignment, returning a String array that MUST contain {@code cellHeight} + * lines, each of which MUST be {@code cellWidth} chars in length. * - *Input array is guaranteed to contain lines that have length equal to {@cellWidth}. There - * is no guarantee on the input number of lines though.
+ *+ * Input array is guaranteed to contain lines that have length equal to {@code cellWidth}. + * There is no guarantee on the input number of lines though. + *
+ * + * @param text the text to align + * @param cellWidth the width of of the table cell + * @param cellHeight the height of the table cell + * @return the aligned text, in a {@code cellHeight} element array */ String[] align(String[] text, int cellWidth, int cellHeight); } diff --git a/src/main/java/org/springframework/shell/table/CellMatcher.java b/src/main/java/org/springframework/shell/table/CellMatcher.java index dda53f14..aee78ec3 100644 --- a/src/main/java/org/springframework/shell/table/CellMatcher.java +++ b/src/main/java/org/springframework/shell/table/CellMatcher.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2017 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. @@ -26,7 +26,10 @@ package org.springframework.shell.table; public interface CellMatcher { /** - * Return whether a given cell of the table should match. + * @return whether a given cell of the table should match. + * @param row the row being tested. + * @param column the column being tested + * @param model the data model of the table */ public boolean matches(int row, int column, TableModel model); } diff --git a/src/main/java/org/springframework/shell/table/CellMatchers.java b/src/main/java/org/springframework/shell/table/CellMatchers.java index f9fdfff3..183c112a 100644 --- a/src/main/java/org/springframework/shell/table/CellMatchers.java +++ b/src/main/java/org/springframework/shell/table/CellMatchers.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2017 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. @@ -24,7 +24,7 @@ package org.springframework.shell.table; public class CellMatchers { /** - * Return a matcher that applies to every cell of the table. + * @return a matcher that applies to every cell of the table. */ public static CellMatcher table() { return new CellMatcher() { @@ -35,7 +35,8 @@ public class CellMatchers { } /** - * Return a matcher that applies to every cell of some column of the table. + * @return a matcher that applies to every cell of some column of the table. + * @param col the column to select */ public static CellMatcher column(final int col) { return new CellMatcher() { @@ -46,7 +47,8 @@ public class CellMatchers { } /** - * Return a matcher that applies to every cell of some row of the table. + * @return a matcher that applies to every cell of some row of the table. + * @param theRow the row to select */ public static CellMatcher row(final int theRow) { return new CellMatcher() { @@ -56,6 +58,10 @@ public class CellMatchers { }; } + /** + * @param clazz the type that cells should contain + * @return a matcher that matches cells whose content is of a certain type + */ public static CellMatcher ofType(final Class> clazz) { return new CellMatcher() { @Override diff --git a/src/main/java/org/springframework/shell/table/SizeConstraints.java b/src/main/java/org/springframework/shell/table/SizeConstraints.java index f81b842b..cec862c6 100644 --- a/src/main/java/org/springframework/shell/table/SizeConstraints.java +++ b/src/main/java/org/springframework/shell/table/SizeConstraints.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2017 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. @@ -26,7 +26,7 @@ import org.springframework.util.Assert; public interface SizeConstraints { /** - * Return the minimum and maximum width of the cell, given its raw content. + * @return the minimum and maximum width of the cell, given its raw content. * @param raw the raw String representation of the cell contents (may be reformatted later, eg wrapped) * @param tableWidth the whole available width for the table * @param nbColumns the number of columns in the table diff --git a/src/main/java/org/springframework/shell/table/Table.java b/src/main/java/org/springframework/shell/table/Table.java index 337f72da..8b7b8402 100644 --- a/src/main/java/org/springframework/shell/table/Table.java +++ b/src/main/java/org/springframework/shell/table/Table.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2017 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. @@ -30,14 +30,14 @@ import org.springframework.shell.TerminalSizeAware; * TableModel, which holds raw table contents. Its rendering logic is then altered by applying * various customizations, in a fashion very similar to what is used e.g. in a spreadsheet * program: