Return-Path: X-Original-To: apmail-commons-dev-archive@www.apache.org Delivered-To: apmail-commons-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2A48710B04 for ; Thu, 1 Aug 2013 23:45:14 +0000 (UTC) Received: (qmail 12760 invoked by uid 500); 1 Aug 2013 23:45:13 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 12657 invoked by uid 500); 1 Aug 2013 23:45:13 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 12649 invoked by uid 99); 1 Aug 2013 23:45:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Aug 2013 23:45:13 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW X-Spam-Check-By: apache.org Received-SPF: error (athena.apache.org: local policy) Received: from [209.85.217.180] (HELO mail-lb0-f180.google.com) (209.85.217.180) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Aug 2013 23:45:08 +0000 Received: by mail-lb0-f180.google.com with SMTP id a16so4388lbj.39 for ; Thu, 01 Aug 2013 16:44:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type :x-gm-message-state; bh=7kZUQVAPXK5QRxUqTCmy8IQU5X1e68Mlg3PFqu7n07o=; b=TH5P53d2pXnnAhZCTam0X5ZsOD6toVG9Z00pnIIddcWaHBHlt43r20AIrgAZv+GalS zp/dG5yjBDdMPF5lc6RX9EcwqoD8G8VJTZmhkCTdIcB+BLI2rqIZrfdE9AwkdzkyftmF yZGRzCzxR2e8aAWgyuNgKHaDRFPEdZBOMuGgBFUneJaTpNI7TNGQ/gsXVbwjjBSf6Dgz YboxarGiBLNe+Nrvav48LG4VRbazLgtOGly4Ul9nhnE+UDy/kxBhCXgRDfjntXgCSI/b XqQQgEKB9dwNMgD+2PqpRgJHL4xTZHD08tqKOF0S/DWO7IxFUmCtO0QpIm5LyvTylf/D cjjg== X-Received: by 10.112.34.209 with SMTP id b17mr2320142lbj.55.1375400666540; Thu, 01 Aug 2013 16:44:26 -0700 (PDT) MIME-Version: 1.0 Sender: jcarman@carmanconsulting.com Received: by 10.112.134.138 with HTTP; Thu, 1 Aug 2013 16:44:06 -0700 (PDT) In-Reply-To: References: <20130801215746.93CF12388831@eris.apache.org> From: James Carman Date: Thu, 1 Aug 2013 19:44:06 -0400 X-Google-Sender-Auth: OjxQGbFRACGLUgNmIzqzCBaySR0 Message-ID: Subject: Re: svn commit: r1509450 - in /commons/proper/csv/trunk/src: main/java/org/apache/commons/csv/CSVRecord.java test/java/org/apache/commons/csv/CSVRecordIntTest.java To: Commons Developers List Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQmWSMcwqi4/uyFedBRcqCO7D5qy+l4HxWDvduvzaMygbFccniNYecmCMo5438V53pj0UYBM X-Virus-Checked: Checked by ClamAV on apache.org You are -1ing a code modification, which means this counts as a veto. Are you sure you want to veto this? On Thu, Aug 1, 2013 at 7:28 PM, sebb wrote: > On 1 August 2013 22:57, wrote: >> Author: ggregory >> Date: Thu Aug 1 21:57:46 2013 >> New Revision: 1509450 >> >> URL: http://svn.apache.org/r1509450 >> Log: >> Add CSVRecord#getInt(String) API and tests. > > -1 > > I think this is out of scope for CSV. > >> Added: >> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVRecordIntTest.java (with props) >> Modified: >> commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java >> >> Modified: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java >> URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java?rev=1509450&r1=1509449&r2=1509450&view=diff >> ============================================================================== >> --- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java (original) >> +++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java Thu Aug 1 21:57:46 2013 >> @@ -146,6 +146,23 @@ public class CSVRecord implements Serial >> * if the record is inconsistent >> * @see #isConsistent() >> */ >> + public int getInt(String name) { >> + String s = this.get(name); >> + return s != null ? Integer.parseInt(s) : 0; >> + } >> + >> + /** >> + * Returns a value by name. >> + * >> + * @param name >> + * the name of the column to be retrieved. >> + * @return the column value >> + * @throws IllegalStateException >> + * if no header mapping was provided >> + * @throws IllegalArgumentException >> + * if the record is inconsistent >> + * @see #isConsistent() >> + */ >> public long getLong(String name) { >> String s = this.get(name); >> return s != null ? Long.parseLong(s) : 0; >> >> Added: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVRecordIntTest.java >> URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVRecordIntTest.java?rev=1509450&view=auto >> ============================================================================== >> --- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVRecordIntTest.java (added) >> +++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVRecordIntTest.java Thu Aug 1 21:57:46 2013 >> @@ -0,0 +1,64 @@ >> +/* >> + * Licensed to the Apache Software Foundation (ASF) under one or more >> + * contributor license agreements. See the NOTICE file distributed with >> + * this work for additional information regarding copyright ownership. >> + * The ASF licenses this file to You 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.apache.commons.csv; >> + >> +import java.io.IOException; >> + >> +import org.junit.Assert; >> +import org.junit.Before; >> +import org.junit.Test; >> + >> +public class CSVRecordIntTest { >> + >> + private CSVRecord record; >> + >> + /** >> + * @return >> + * @throws IOException >> + */ >> + private CSVRecord createTestRecord() throws IOException { >> + String csv = "A, B, C, D, E\n-1, 0, 1, " + Integer.MAX_VALUE + ", " + Integer.MIN_VALUE; >> + CSVRecord record = CSVParser.parseString(csv, CSVFormat.DEFAULT.withHeader().withIgnoreSurroundingSpaces(true)) >> + .iterator().next(); >> + return record; >> + } >> + >> + @Before >> + public void setUp() throws IOException { >> + this.record = createTestRecord(); >> + } >> + >> + @Test(expected = IllegalArgumentException.class) >> + public void testGetIntegerByMissingString() { >> + Assert.assertEquals(null, Integer.valueOf(record.getInt("ABSENT"))); >> + } >> + >> + @Test(expected = IllegalArgumentException.class) >> + public void testGetIntegerByNullString() { >> + Assert.assertEquals(null, Integer.valueOf(record.getInt(null))); >> + } >> + >> + @Test >> + public void testGetIntegerByString() { >> + Assert.assertEquals(-1, record.getInt("A")); >> + Assert.assertEquals(0, record.getInt("B")); >> + Assert.assertEquals(1, record.getInt("C")); >> + Assert.assertEquals(Integer.MAX_VALUE, record.getInt("D")); >> + Assert.assertEquals(Integer.MIN_VALUE, record.getInt("E")); >> + } >> + >> +} >> >> Propchange: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVRecordIntTest.java >> ------------------------------------------------------------------------------ >> svn:eol-style = native >> >> Propchange: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVRecordIntTest.java >> ------------------------------------------------------------------------------ >> svn:keywords = Id >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org > For additional commands, e-mail: dev-help@commons.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org