Skip to content

Commit

Permalink
Version 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
moncho-mendez authored and mnloures committed Feb 3, 2021
1 parent eb7b122 commit 5b22e46
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<groupId>org.bdp4j</groupId>
<artifactId>bdp4j</artifactId>
<version>2.0.0-SNAPSHOT</version>
<version>1.0.2</version>

<name>BDP4J</name>
<inceptionYear>2018</inceptionYear>
Expand Down Expand Up @@ -98,12 +98,12 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.11.1</version>
<version>2.13.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.11.1</version>
<version>2.13.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
88 changes: 88 additions & 0 deletions src/main/java/org/bdp4j/transformers/Url2BinaryTransformer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*-
* #%L
* BDP4J
* %%
* Copyright (C) 2018 - 2019 SING Group (University of Vigo)
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.bdp4j.transformers;

import java.util.ArrayList;
import java.util.List;
import org.bdp4j.types.Transformer;

/**
* Transform an input url to double, that represents if this input has an url or
* not.
*
* @author María Novo
*/
public class Url2BinaryTransformer extends Transformer {

private String transformerListValues;

/**
* Transform an input url to double, that represents if this input has an
* url or not.
*
* @param input A url to transform in 0 or 1
* @return A double value that represents if contains a url or not
*/
@Override
public double transform(Object input) {
try {
return (((input.toString().indexOf("http:")) != -1 || (input.toString().indexOf("https:")) != -1 || (input.toString().indexOf("www.")) != -1) ? 1 : 0);
} catch (NullPointerException ex) {
return 0;
}
}

/**
* Get a String who contains the meaning of the transformated values
*
* @return String who contains the meaning of the transformated values
*/
@Override
public String getTransformerListValues() {
return transformerListValues;
}

/**
* Get a List who contains the transformated values
*
* @return List who contains the transformated values
*/
@Override
public Class<?> getInputType() {
return String.class;
}

/**
* Get a List who contains the values
*
* @return List who contains the values
*/
@Override
public List<Integer> getListValues() {
return new ArrayList<>();
}
}

0 comments on commit 5b22e46

Please sign in to comment.