commit
979058579a
@ -125,11 +125,9 @@ public class ExpressionUtils {
|
|||||||
|
|
||||||
static public boolean sameValue(Object v1, Object v2) {
|
static public boolean sameValue(Object v1, Object v2) {
|
||||||
if (v1 == null) {
|
if (v1 == null) {
|
||||||
return (v2 == null)
|
return (v2 == null) ;
|
||||||
|| (v2 instanceof String && ((String) v2).length() == 0);
|
|
||||||
} else if (v2 == null) {
|
} else if (v2 == null) {
|
||||||
return (v1 == null)
|
return (v1 == null);
|
||||||
|| (v1 instanceof String && ((String) v1).length() == 0);
|
|
||||||
} else {
|
} else {
|
||||||
return v1.equals(v2);
|
return v1.equals(v2);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Copyright 2017, Owen Stephens
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
|
in the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
* Neither the name of the copyright holder nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.google.refine.tests.expr.functions;
|
||||||
|
|
||||||
|
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.testng.Assert;
|
||||||
|
import org.testng.annotations.BeforeTest;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.refine.expr.ExpressionUtils;
|
||||||
|
import com.google.refine.tests.RefineTest;
|
||||||
|
|
||||||
|
|
||||||
|
public class ExpressionUtilsTests extends RefineTest {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@BeforeTest
|
||||||
|
public void init() {
|
||||||
|
logger = LoggerFactory.getLogger(this.getClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------tests------------
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSameValueTrue() {
|
||||||
|
Assert.assertTrue(ExpressionUtils.sameValue(null,null));
|
||||||
|
Assert.assertTrue(ExpressionUtils.sameValue("",""));
|
||||||
|
Assert.assertTrue(ExpressionUtils.sameValue("one","one"));
|
||||||
|
Assert.assertTrue(ExpressionUtils.sameValue(1,1));
|
||||||
|
Assert.assertTrue(ExpressionUtils.sameValue(1.0,1.00));
|
||||||
|
Assert.assertTrue(ExpressionUtils.sameValue(true,true));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSameValueFalse() {
|
||||||
|
Assert.assertFalse(ExpressionUtils.sameValue("",null));
|
||||||
|
Assert.assertFalse(ExpressionUtils.sameValue(null,""));
|
||||||
|
Assert.assertFalse(ExpressionUtils.sameValue("one","two"));
|
||||||
|
Assert.assertFalse(ExpressionUtils.sameValue(1,2));
|
||||||
|
Assert.assertFalse(ExpressionUtils.sameValue(1,1.0));
|
||||||
|
Assert.assertFalse(ExpressionUtils.sameValue(true,false));
|
||||||
|
}
|
||||||
|
}
|
@ -614,7 +614,8 @@
|
|||||||
"to-number": "To number",
|
"to-number": "To number",
|
||||||
"to-date": "To date",
|
"to-date": "To date",
|
||||||
"to-text": "To text",
|
"to-text": "To text",
|
||||||
"blank-out": "Blank out cells",
|
"blank-out": "To null",
|
||||||
|
"blank-out-empty": "To empty string",
|
||||||
"fill-down": "Fill down",
|
"fill-down": "Fill down",
|
||||||
"blank-down": "Blank down",
|
"blank-down": "Blank down",
|
||||||
"split-cells": "Split multi-valued cells",
|
"split-cells": "Split multi-valued cells",
|
||||||
|
@ -576,7 +576,7 @@
|
|||||||
"to-number": "A número",
|
"to-number": "A número",
|
||||||
"to-date": "A fecha",
|
"to-date": "A fecha",
|
||||||
"to-text": "A texto",
|
"to-text": "A texto",
|
||||||
"blank-out": "Vaciar Celdas",
|
"blank-out": "Establecer celdas en nulo",
|
||||||
"fill-down": "Llenar hacia abajo",
|
"fill-down": "Llenar hacia abajo",
|
||||||
"blank-down": "Vaciar hacia abajo",
|
"blank-down": "Vaciar hacia abajo",
|
||||||
"split-cells": "Dividir celdas multi-valuadas",
|
"split-cells": "Dividir celdas multi-valuadas",
|
||||||
|
@ -475,7 +475,7 @@
|
|||||||
"re-trans": "Muling ibahin ang hanggang sa",
|
"re-trans": "Muling ibahin ang hanggang sa",
|
||||||
"warning-no-length": "Hindi tinukoy ang haba ng patlang.",
|
"warning-no-length": "Hindi tinukoy ang haba ng patlang.",
|
||||||
"discard-judg": "Itapon ang mga hatol sa pagkakasundo",
|
"discard-judg": "Itapon ang mga hatol sa pagkakasundo",
|
||||||
"blank-out": "Mga blankong cell",
|
"blank-out": "Itakda ang mga cell sa null",
|
||||||
"best-cand-type-match": "tumutugma sa mga uri ng pinakamahusay na kandidato?",
|
"best-cand-type-match": "tumutugma sa mga uri ng pinakamahusay na kandidato?",
|
||||||
"sort-by-col": "ayusin ayon sa hanay na ito lamang",
|
"sort-by-col": "ayusin ayon sa hanay na ito lamang",
|
||||||
"enter-col-name": "Magpasok ng bagong pangalan ng haligi",
|
"enter-col-name": "Magpasok ng bagong pangalan ng haligi",
|
||||||
|
@ -476,7 +476,7 @@
|
|||||||
"remove-matching": "Supprimer les lignes correspondantes",
|
"remove-matching": "Supprimer les lignes correspondantes",
|
||||||
"warning-no-length": "Aucune longueur de champ n’a été indiquée.",
|
"warning-no-length": "Aucune longueur de champ n’a été indiquée.",
|
||||||
"discard-judg": "Rejeter les avis de réconciliation",
|
"discard-judg": "Rejeter les avis de réconciliation",
|
||||||
"blank-out": "Vider les cellules",
|
"blank-out": "Définir les cellules sur null",
|
||||||
"best-cand-type-match": "Meilleure correspondance de type des candidats ?",
|
"best-cand-type-match": "Meilleure correspondance de type des candidats ?",
|
||||||
"sort-by-col": "trier selon cette seule colonne",
|
"sort-by-col": "trier selon cette seule colonne",
|
||||||
"enter-col-name": "Indiquer le nom de la nouvelle colonne",
|
"enter-col-name": "Indiquer le nom de la nouvelle colonne",
|
||||||
|
@ -578,7 +578,9 @@
|
|||||||
"to-number": "To number",
|
"to-number": "To number",
|
||||||
"to-date": "To date",
|
"to-date": "To date",
|
||||||
"to-text": "To text",
|
"to-text": "To text",
|
||||||
"blank-out": "Blank out cells",
|
"blank-out": "To null",
|
||||||
|
"blank-out-empty": "To empty string",
|
||||||
|
"empty-cells": "Set cells to empty string",
|
||||||
"fill-down": "Fill down",
|
"fill-down": "Fill down",
|
||||||
"blank-down": "Blank down",
|
"blank-down": "Blank down",
|
||||||
"split-cells": "Split multi-valued cells",
|
"split-cells": "Split multi-valued cells",
|
||||||
|
@ -474,7 +474,7 @@
|
|||||||
"re-trans": "Ritrasforma fino a",
|
"re-trans": "Ritrasforma fino a",
|
||||||
"warning-no-length": "Nessuna lunghezza dei campi specificata.",
|
"warning-no-length": "Nessuna lunghezza dei campi specificata.",
|
||||||
"discard-judg": "Annulla i match dei candidati",
|
"discard-judg": "Annulla i match dei candidati",
|
||||||
"blank-out": "Cancella tutte le celle",
|
"blank-out": "Imposta le celle su null",
|
||||||
"best-cand-type-match": "miglior match del tipo del candidato?",
|
"best-cand-type-match": "miglior match del tipo del candidato?",
|
||||||
"sort-by-col": "ordina per questa colonna",
|
"sort-by-col": "ordina per questa colonna",
|
||||||
"enter-col-name": "Inserisci il nome della nuova colonna",
|
"enter-col-name": "Inserisci il nome della nuova colonna",
|
||||||
|
@ -467,7 +467,7 @@
|
|||||||
"uppercase": "Para maiúsculo",
|
"uppercase": "Para maiúsculo",
|
||||||
"best-type": "Best candidate's types",
|
"best-type": "Best candidate's types",
|
||||||
"discard-judg": "Descartar a análise de reconciliação",
|
"discard-judg": "Descartar a análise de reconciliação",
|
||||||
"blank-out": "Limpar células",
|
"blank-out": "Definir células para nulo",
|
||||||
"best-cand-type-match": "best candidate's types match?",
|
"best-cand-type-match": "best candidate's types match?",
|
||||||
"sort-by-col": "ordenar somente esta coluna",
|
"sort-by-col": "ordenar somente esta coluna",
|
||||||
"enter-col-name": "Digite um nome para a nova coluna",
|
"enter-col-name": "Digite um nome para a nova coluna",
|
||||||
|
@ -268,6 +268,11 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
|
|||||||
id: "core/to-blank",
|
id: "core/to-blank",
|
||||||
label: $.i18n._('core-views')["blank-out"],
|
label: $.i18n._('core-views')["blank-out"],
|
||||||
click: function() { doTextTransform("null", "keep-original", false, ""); }
|
click: function() { doTextTransform("null", "keep-original", false, ""); }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "core/to-empty",
|
||||||
|
label: $.i18n._('core-views')["blank-out-empty"],
|
||||||
|
click: function() { doTextTransform("\"\"", "keep-original", false, ""); }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user