|
| 1 | +/* |
| 2 | + * #%L |
| 3 | + * ImageJ software for multidimensional image processing and analysis. |
| 4 | + * %% |
| 5 | + * Copyright (C) 2009 - 2017 Board of Regents of the University of |
| 6 | + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck |
| 7 | + * Institute of Molecular Cell Biology and Genetics. |
| 8 | + * %% |
| 9 | + * Redistribution and use in source and binary forms, with or without |
| 10 | + * modification, are permitted provided that the following conditions are met: |
| 11 | + * |
| 12 | + * 1. Redistributions of source code must retain the above copyright notice, |
| 13 | + * this list of conditions and the following disclaimer. |
| 14 | + * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 15 | + * this list of conditions and the following disclaimer in the documentation |
| 16 | + * and/or other materials provided with the distribution. |
| 17 | + * |
| 18 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 19 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 20 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 21 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE |
| 22 | + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 23 | + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 24 | + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 25 | + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 26 | + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 27 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 28 | + * POSSIBILITY OF SUCH DAMAGE. |
| 29 | + * #L% |
| 30 | + */ |
| 31 | + |
| 32 | +package org.scijava.table; |
| 33 | + |
| 34 | +import org.scijava.util.CharArray; |
| 35 | + |
| 36 | +/** |
| 37 | + * Efficient implementation of {@link Column} for {@code char} primitives. |
| 38 | + * |
| 39 | + * @author Alison Walter |
| 40 | + */ |
| 41 | +public class CharColumn extends CharArray implements |
| 42 | + PrimitiveColumn<char[], Character> |
| 43 | +{ |
| 44 | + |
| 45 | + /** The column header. */ |
| 46 | + private String header; |
| 47 | + |
| 48 | + public CharColumn() {} |
| 49 | + |
| 50 | + public CharColumn(final String header) { |
| 51 | + this.header = header; |
| 52 | + } |
| 53 | + |
| 54 | + // -- Column methods -- |
| 55 | + |
| 56 | + @Override |
| 57 | + public String getHeader() { |
| 58 | + return header; |
| 59 | + } |
| 60 | + |
| 61 | + @Override |
| 62 | + public void setHeader(final String header) { |
| 63 | + this.header = header; |
| 64 | + } |
| 65 | + |
| 66 | + @Override |
| 67 | + public Class<Character> getType() { |
| 68 | + return Character.class; |
| 69 | + } |
| 70 | + |
| 71 | + // -- PrimitiveColumn methods -- |
| 72 | + |
| 73 | + @Override |
| 74 | + public void fill(final char[] values) { |
| 75 | + setArray(values.clone()); |
| 76 | + setSize(values.length); |
| 77 | + } |
| 78 | + |
| 79 | + @Override |
| 80 | + public void fill(final char[] values, final int offset) { |
| 81 | + // Check if array has been initialized |
| 82 | + if (getArray() == null) setArray(values.clone()); |
| 83 | + else { |
| 84 | + System.arraycopy(values, 0, getArray(), offset, values.length); |
| 85 | + } |
| 86 | + setSize(values.length); |
| 87 | + } |
| 88 | + |
| 89 | +} |
0 commit comments