/*
 * ARX: Powerful Data Anonymization
 * Copyright 2014 Karol Babioch <karol@babioch.de>
 * 
 * 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.deidentifier.arx.examples;

import java.io.IOException;
import java.sql.SQLException;

import org.deidentifier.arx.Data;
import org.deidentifier.arx.DataSource;
import org.deidentifier.arx.DataType;

/**
 * This class implements an example on how to use data cleansing using the DataSource functionality.
 * 
 * @author Florian Kohlmayer
 * @author Fabian Prasser
 */
public class Example28 extends Example {

    /**
     * Main entry point.
     *
     * @param args
     * @throws IOException
     * @throws SQLException
     * @throws ClassNotFoundException
     */
    public static void main(final String[] args) throws IOException,
                                                SQLException,
                                                ClassNotFoundException {

        exampleCSV();
        // exampleExcel();
        // exampleJDBC();
    }

    /**
     * This method imports data from a simple CSV file, set a data type and replace all non-matching values with NULL values.
     *
     * @throws IOException
     */
    private static void exampleCSV() throws IOException {

        DataSource source = DataSource.createCSVSource("data/test_dirty.csv", ';', true);
        source.addColumn("age", DataType.INTEGER, true);

        // Create data object
        final Data data = Data.create(source);

        // Print to console
        print(data.getHandle());
        System.out.println("\n");
    }

}

@@ -776,90 +776,390 @@
 arx.
-Data;%0Aimport org.deidentifier.arx.DataSource;%0Aimport org.deidentifier.arx.DataType
+ARXAnonymizer;%0Aimport org.deidentifier.arx.ARXConfiguration;%0Aimport org.deidentifier.arx.ARXResult;%0Aimport org.deidentifier.arx.Data;%0Aimport org.deidentifier.arx.DataSource;%0Aimport org.deidentifier.arx.DataType;%0Aimport org.deidentifier.arx.AttributeType.Hierarchy;%0Aimport org.deidentifier.arx.AttributeType.Hierarchy.DefaultHierarchy;%0Aimport org.deidentifier.arx.criteria.KAnonymity
 ;%0A%0A/
@@ -2290,91 +2290,862 @@
  // 
-Print to console%0A        print(data.getHandle());%0A        System.out.println(%22%5Cn%22);
+Define hierarchies%0A        final DefaultHierarchy age = Hierarchy.create();%0A        age.add(%2234%22, %22%3C50%22, %22*%22);%0A        age.add(%2245%22, %22%3C50%22, %22*%22);%0A        age.add(%2266%22, %22%3E=50%22, %22*%22);%0A        age.add(%2270%22, %22%3E=50%22, %22*%22);%0A        age.add(%2299%22, %22%3E=50%22, %22*%22);%0A        age.add(null, %22%3E=50%22, %22*%22);%0A%0A        data.getDefinition().setAttributeType(%22age%22, age);%0A%0A        // Print to console%0A        print(data.getHandle());%0A        System.out.println(%22%5Cn%22);%0A%0A        // Anonymize%0A        final ARXAnonymizer anonymizer = new ARXAnonymizer();%0A        final ARXConfiguration config = ARXConfiguration.create();%0A        config.addCriterion(new KAnonymity(3));%0A        config.setMaxOutliers(0d);%0A        final ARXResult result = anonymizer.anonymize(data, config);%0A%0A        // Print results%0A        System.out.println(%22Output:%22);%0A        print(result.getOutput(false));%0A
 %0A   

Modify example