Example usage for java.util Scanner next

List of usage examples for java.util Scanner next

Introduction

In this page you can find the example usage for java.util Scanner next.

Prototype

public String next() 

Source Link

Document

Finds and returns the next complete token from this scanner.

Usage

From source file:Balo.MainFrame.java

public void getDataFileToJTable() {
    String fileNameDefined = "src/Balo/Data_1.csv";
    File file = new File(fileNameDefined);
    int i = 0;/* www  . java 2  s .  c o m*/

    dvDynamic[0] = new Dovat();
    //Get value from csv file
    try {
        Scanner inputStream = new Scanner(file);
        inputStream.useDelimiter(",");
        while (inputStream.hasNext()) {
            dvDynamic[i + 1] = dvGreedy[i] = new Dovat();
            dvDynamic[i + 1].ten = dvGreedy[i].ten = inputStream.next().trim();
            dvDynamic[i + 1].soluong = dvGreedy[i].soluong = Integer.valueOf(inputStream.next().trim());
            dvDynamic[i + 1].giatri = dvGreedy[i].giatri = Integer.valueOf(inputStream.next().trim());
            dvDynamic[i + 1].trongluong = dvGreedy[i].trongluong = Integer.valueOf(inputStream.next().trim());
            i++;
        }
        //Set number of Items
        numOfItem = i;
        //Get weight bag
        weightBag = Integer.parseInt(TextW.getText());
        inputStream.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }

    //Set value for JTable
    for (int item = 0; item < numOfItem; item++) {
        Object[] row = new Object[4];
        row[0] = dvGreedy[item].ten;
        row[1] = dvGreedy[item].soluong;
        row[2] = dvGreedy[item].giatri;
        row[3] = dvGreedy[item].trongluong;
        model.addRow(row);
    }
}

From source file:decision_tree_learning.Matrix.java

public void loadArff(String filename) throws Exception, FileNotFoundException {
    m_data = new ArrayList<double[]>();
    m_attr_name = new ArrayList<String>();
    m_str_to_enum = new ArrayList<TreeMap<String, Integer>>();
    m_enum_to_str = new ArrayList<TreeMap<Integer, String>>();
    boolean READDATA = false;
    Scanner s = new Scanner(new File(filename));
    while (s.hasNext()) {
        String line = s.nextLine().trim();
        if (line.length() > 0 && line.charAt(0) != '%') {
            if (!READDATA) {

                Scanner t = new Scanner(line);
                String firstToken = t.next().toUpperCase();

                if (firstToken.equals("@RELATION")) {
                    String datasetName = t.nextLine();
                }//from w ww .  j a  va2s . c o  m

                if (firstToken.equals("@ATTRIBUTE")) {
                    TreeMap<String, Integer> ste = new TreeMap<String, Integer>();
                    m_str_to_enum.add(ste);
                    TreeMap<Integer, String> ets = new TreeMap<Integer, String>();
                    m_enum_to_str.add(ets);

                    Scanner u = new Scanner(line);
                    if (line.indexOf("'") != -1)
                        u.useDelimiter("'");
                    u.next();
                    String attributeName = u.next();
                    if (line.indexOf("'") != -1)
                        attributeName = "'" + attributeName + "'";
                    m_attr_name.add(attributeName);

                    int vals = 0;
                    String type = u.next().trim().toUpperCase();
                    if (type.equals("REAL") || type.equals("CONTINUOUS") || type.equals("INTEGER")
                            || type.equals("NUMERIC")) {
                    } else {
                        try {
                            String values = line.substring(line.indexOf("{") + 1, line.indexOf("}"));
                            Scanner v = new Scanner(values);
                            v.useDelimiter(",");
                            while (v.hasNext()) {
                                String value = v.next().trim();
                                if (value.length() > 0) {
                                    ste.put(value, new Integer(vals));
                                    ets.put(new Integer(vals), value);
                                    vals++;
                                }
                            }
                        } catch (Exception e) {
                            throw new Exception("Error parsing line: " + line + "\n" + e.toString());
                        }
                    }
                }
                if (firstToken.equals("@DATA")) {
                    READDATA = true;
                }
            } else {
                double[] newrow = new double[cols()];
                int curPos = 0;

                try {
                    Scanner t = new Scanner(line);
                    t.useDelimiter(",");
                    while (t.hasNext()) {
                        String textValue = t.next().trim();
                        //System.out.println(textValue);

                        if (textValue.length() > 0) {
                            double doubleValue;
                            int vals = m_enum_to_str.get(curPos).size();

                            //Missing instances appear in the dataset as a double defined as MISSING
                            if (textValue.equals("?")) {
                                missing_val = true;

                                doubleValue = MISSING;
                            }
                            // Continuous values appear in the instance vector as they are
                            else if (vals == 0) {
                                doubleValue = Double.parseDouble(textValue);
                            }
                            // Discrete values appear as an index to the "name" 
                            // of that value in the "attributeValue" structure
                            else {
                                doubleValue = m_str_to_enum.get(curPos).get(textValue);
                                if (doubleValue == -1) {
                                    throw new Exception(
                                            "Error parsing the value '" + textValue + "' on line: " + line);
                                }
                            }

                            newrow[curPos] = doubleValue;
                            curPos++;
                        }
                    }
                } catch (Exception e) {
                    throw new Exception("Error parsing line: " + line + "\n" + e.toString());
                }
                m_data.add(newrow);
            }
        }
    }
    if (hasMissing())
        postmodifyMetadata();
}

From source file:uk.bl.wa.annotation.AnnotationsFromAct.java

/**
 * Read data from ACT to include curator-specified metadata.
 * @param conf/* w  w  w .j a  v  a 2s . c o m*/
 * @return
 * @throws MalformedURLException
 * @throws IOException
 */
private String readAct(String url) throws IOException {
    URL act = new URL(url);
    HttpURLConnection connection = (HttpURLConnection) act.openConnection();
    if (this.cookie != null) {
        connection.setRequestProperty("Cookie", this.cookie);
        connection.setRequestProperty("X-CSRF-TOKEN", this.csrf);
    }

    Scanner scanner;
    if (connection.getResponseCode() != 200) {
        scanner = new Scanner(connection.getErrorStream());
        scanner.useDelimiter("\\Z");
        throw new IOException(scanner.next());
    } else {
        scanner = new Scanner(connection.getInputStream());
    }
    scanner.useDelimiter("\\Z");
    return scanner.next();
}

From source file:uk.bl.wa.annotation.AnnotationsFromAct.java

/**
 * Performs login operation to ACT, setting Cookie and CSRF.
 * @throws IOException/*from   w w  w.j a  v  a  2s.  c o  m*/
 */
private void actLogin() throws IOException {
    Config loginConf = ConfigFactory.parseFile(new File("credentials.conf"));
    URL login = new URL(loginConf.getString("act.login"));
    LOG.info("Logging in at " + login);

    HttpURLConnection connection = (HttpURLConnection) login.openConnection();
    StringBuilder credentials = new StringBuilder();
    credentials.append(loginConf.getString("act.username"));
    credentials.append(":");
    credentials.append(loginConf.getString("act.password"));
    connection.setRequestProperty("Authorization",
            "Basic " + Base64.byteArrayToBase64(credentials.toString().getBytes()));
    connection.setRequestProperty("Content-Type", "text/plain");

    Scanner scanner;
    if (connection.getResponseCode() != 200) {
        scanner = new Scanner(connection.getErrorStream());
        scanner.useDelimiter("\\Z");
        throw new IOException(scanner.next());
    } else {
        scanner = new Scanner(connection.getInputStream());
    }
    scanner.useDelimiter("\\Z");
    this.csrf = scanner.next();
    this.cookie = connection.getHeaderField("set-cookie");
}

From source file:simulation.AureoZauleckAnsLab2.java

public static void DisplayTables(double k, ArrayList<Double> cl, ArrayList<Double> cl2, ArrayList<Double> tlcl,
        ArrayList<Double> tucl, ArrayList<Double> midList, ArrayList<ArrayList<Double>> freq,
        ArrayList<Double> freqPercent, ArrayList<Double> cfs, ArrayList<Double> cps, String title) {

    JFrame frame = new JFrame();
    //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);                        
    JTable table = new JTable();
    table.setModel(new DefaultTableModel((int) (k + 2), 7));

    table.setValueAt("CLASS LIMITS", 0, 0);
    table.setValueAt("TRUE CLASS LIMITS", 0, 1);
    table.setValueAt("MIDPOINTS", 0, 2);
    table.setValueAt("FREQUENCY", 0, 3);
    table.setValueAt("%", 0, 4);
    table.setValueAt("CF", 0, 5);
    table.setValueAt("C%", 0, 6);
    table.setValueAt("n = " + N, (int) (k + 1), 3);
    table.setValueAt("TOTAL = 100%", (int) (k + 1), 4);

    for (int i = 0; i < k; i++) {
        table.setValueAt(cl.get(i) + " - " + cl2.get(i), i + 1, 0);
        table.setValueAt(tlcl.get(i) + " - " + tucl.get(i), i + 1, 1);
        table.setValueAt(midList.get(i), i + 1, 2);
        table.setValueAt(freq.get(i).size(), i + 1, 3);
        table.setValueAt(new DecimalFormat("#.##").format(freqPercent.get(i)), i + 1, 4);
        table.setValueAt(cfs.get(i), i + 1, 5);
        table.setValueAt(new DecimalFormat("#.##").format(cps.get(i)), i + 1, 6);
    }// www.ja va 2 s.c o m

    JScrollPane scrollPane = new JScrollPane(table);
    scrollPane.setBorder(BorderFactory.createTitledBorder(title));
    frame.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(300, 150);
    frame.setVisible(true);

    Scanner sc = new Scanner(System.in);

    int type = 0, testT = 0;
    String typeTest = "";
    do {

        System.out.println();
        System.out.println("COLLAPSE CLASS LIMITS?");
        System.out.println("[1] COLLAPSE LOWER CLASS LIMIT");
        System.out.println("[2] COLLAPSE UPPPER CLASS LIMIT");
        System.out.println("[3] COLLAPSE BOTH");
        System.out.println("[4] DON'T COLLAPSE");

        System.out.println();
        System.out.println("Please pick a number from the choices above.");

        typeTest = sc.next();

        if (IsNumber(typeTest)) {
            testT = Convert(typeTest);
        } else {
            do {
                System.out.println("Please enter a number only.");
                typeTest = sc.next();
            } while (!IsNumber(typeTest));

            testT = Convert(typeTest);
        }
        type = testT;
    } while (type < 1 || type > 4);

    if (type == 1) {

        JFrame frame2 = new JFrame();
        //frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);                        
        JTable table2 = new JTable();
        table2.setModel(new DefaultTableModel((int) (k + 2), 7));

        table2.setValueAt("CLASS LIMITS", 0, 0);
        table2.setValueAt("TRUE CLASS LIMITS", 0, 1);
        table2.setValueAt("MIDPOINTS", 0, 2);
        table2.setValueAt("FREQUENCY", 0, 3);
        table2.setValueAt("%", 0, 4);
        table2.setValueAt("CF", 0, 5);
        table2.setValueAt("C%", 0, 6);
        table2.setValueAt("n = " + N, (int) (k + 1), 3);
        table2.setValueAt("TOTAL = 100%", (int) (k + 1), 4);

        for (int i = 0; i < k; i++) {
            table2.setValueAt(cl.get(i) + " - " + cl2.get(i), i + 1, 0);
            table2.setValueAt(tlcl.get(i) + " - " + tucl.get(i), i + 1, 1);
            table2.setValueAt(midList.get(i), i + 1, 2);
            table2.setValueAt(freq.get(i).size(), i + 1, 3);
            table2.setValueAt(new DecimalFormat("#.##").format(freqPercent.get(i)), i + 1, 4);
            table2.setValueAt(cfs.get(i), i + 1, 5);
            table2.setValueAt(new DecimalFormat("#.##").format(cps.get(i)), i + 1, 6);
        }
        table2.setValueAt("below " + cl2.get(0), 1, 0);
        table2.setValueAt(" - ", 1, 1);
        table2.setValueAt(" - ", 1, 2);

        JScrollPane scrollPane2 = new JScrollPane(table2);

        scrollPane2.setBorder(BorderFactory.createTitledBorder(title));
        frame2.add(scrollPane2, BorderLayout.CENTER);
        frame2.setSize(300, 150);
        frame2.setVisible(true);

    } else if (type == 2) {

        JFrame frame3 = new JFrame();
        //frame3.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);                        
        JTable table3 = new JTable();
        table3.setModel(new DefaultTableModel((int) (k + 2), 7));

        table3.setValueAt("CLASS LIMITS", 0, 0);
        table3.setValueAt("TRUE CLASS LIMITS", 0, 1);
        table3.setValueAt("MIDPOINTS", 0, 2);
        table3.setValueAt("FREQUENCY", 0, 3);
        table3.setValueAt("%", 0, 4);
        table3.setValueAt("CF", 0, 5);
        table3.setValueAt("C%", 0, 6);
        table3.setValueAt("n = " + N, (int) (k + 1), 3);
        table3.setValueAt("TOTAL = 100%", (int) (k + 1), 4);
        int a = (int) k;

        for (int i = 0; i < k; i++) {
            table3.setValueAt(cl.get(i) + " - " + cl2.get(i), i + 1, 0);
            table3.setValueAt(tlcl.get(i) + " - " + tucl.get(i), i + 1, 1);
            table3.setValueAt(midList.get(i), i + 1, 2);
            table3.setValueAt(freq.get(i).size(), i + 1, 3);
            table3.setValueAt(new DecimalFormat("#.##").format(freqPercent.get(i)), i + 1, 4);
            table3.setValueAt(cfs.get(i), i + 1, 5);
            table3.setValueAt(new DecimalFormat("#.##").format(cps.get(i)), i + 1, 6);
        }
        table3.setValueAt(cl.get(a - 1) + " above", a, 0);
        table3.setValueAt(" - ", a, 1);
        table3.setValueAt(" - ", a, 2);

        JScrollPane scrollPane3 = new JScrollPane(table3);
        scrollPane3.setBorder(BorderFactory.createTitledBorder(title));
        frame3.add(scrollPane3, BorderLayout.CENTER);

        frame3.setSize(300, 150);
        frame3.setVisible(true);
    }

    else if (type == 3) {
        JFrame frame4 = new JFrame();
        //frame4.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);                        
        JTable table4 = new JTable();
        table4.setModel(new DefaultTableModel((int) (k + 2), 7));
        table4.setValueAt("CLASS LIMITS", 0, 0);
        table4.setValueAt("TRUE CLASS LIMITS", 0, 1);
        table4.setValueAt("MIDPOINTS", 0, 2);
        table4.setValueAt("FREQUENCY", 0, 3);
        table4.setValueAt("%", 0, 4);
        table4.setValueAt("CF", 0, 5);
        table4.setValueAt("C%", 0, 6);
        table4.setValueAt("n = " + N, (int) (k + 1), 3);
        table4.setValueAt("TOTAL = 100%", (int) (k + 1), 4);

        int a = (int) k;

        for (int i = 0; i < k; i++) {
            table4.setValueAt(cl.get(i) + " - " + cl2.get(i), i + 1, 0);
            table4.setValueAt(tlcl.get(i) + " - " + tucl.get(i), i + 1, 1);
            table4.setValueAt(midList.get(i), i + 1, 2);
            table4.setValueAt(freq.get(i).size(), i + 1, 3);
            table4.setValueAt(new DecimalFormat("#.##").format(freqPercent.get(i)), i + 1, 4);
            table4.setValueAt(cfs.get(i), i + 1, 5);
            table4.setValueAt(new DecimalFormat("#.##").format(cps.get(i)), i + 1, 6);
        }
        table4.setValueAt("below " + cl2.get(0), 1, 0);
        table4.setValueAt(cl.get(a - 1) + " above", a, 0);
        table4.setValueAt(" - ", 1, 1);
        table4.setValueAt(" - ", 1, 2);
        table4.setValueAt(" - ", a, 1);
        table4.setValueAt(" - ", a, 2);

        JScrollPane scrollPane4 = new JScrollPane(table4);
        scrollPane4.setBorder(BorderFactory.createTitledBorder(title));
        frame4.add(scrollPane4, BorderLayout.CENTER);

        frame4.setSize(300, 150);
        frame4.setVisible(true);
    } else {

    }
}

From source file:com.jayway.restassured.internal.http.URIBuilder.java

/**
 * Adds all parameters within the Scanner to the list of
 * <code>parameters</code>, as encoded by <code>encoding</code>. For
 * example, a scanner containing the string <code>a=1&b=2&c=3</code> would
 * add the {@link NameValuePair NameValuePairs} a=1, b=2, and c=3 to the
 * list of parameters.//  w  ww  .j  a  va 2  s  .  com
 * <p>
 * Note that this method has been copied from {@link URLEncodedUtils#parse(java.util.List, java.util.Scanner, String)} but it doesn't do URL decoding.
 * </p>
 */
private List<NameValuePair> parse(URI uri) {
    List<NameValuePair> parameters = new ArrayList<NameValuePair>();
    final String query = uri.getRawQuery();
    if (query != null && query.length() > 0) {
        final Scanner scanner = new Scanner(query);
        scanner.useDelimiter(PARAMETER_SEPARATOR);
        while (scanner.hasNext()) {
            String name;
            String value = null;
            String token = scanner.next();
            int i = token.indexOf(NAME_VALUE_SEPARATOR);
            if (i != -1) {
                name = token.substring(0, i).trim();
                value = token.substring(i + 1).trim();
            } else {
                name = token.trim();
            }
            parameters.add(new BasicNameValuePair(name, value));
        }
    }
    return parameters;
}

From source file:com.continuent.tungsten.common.security.KeystoreManagerCtrl.java

/**
 * Reads user input from stdin//from   w  w w  .  ja va2  s.  c  om
 * 
 * @param listPrompts list of prompts to display, asking for user input
 * @return a list containing user inputs
 */
private List<String> getUserInputFromStdin(List<String> listPrompts) {
    List<String> listUserInput = new ArrayList<String>();

    Scanner console = new Scanner(System.in);
    Scanner lineTokenizer = null;

    for (String prompt : listPrompts) {
        System.out.println(prompt);

        try {
            lineTokenizer = new Scanner(console.nextLine());
        } catch (NoSuchElementException nse) {
            console.close();
            throw new NoSuchElementException(MessageFormat.format("Missing user input=  {0}", prompt));
        }

        if (lineTokenizer.hasNext()) {
            String userInput = lineTokenizer.next();
            listUserInput.add(userInput);
        }
    }

    console.close();
    return listUserInput;
}

From source file:eremeykin.pete.plotter.PolarPlotterTopComponent.java

@Override
public void update() {
    // for first rpt file
    if (model == null) {
        clear();//from   w  w w  . j  a v  a  2s.  c  om
        return;
    }
    File[] rptFiles = home.listFiles(filter());
    // catch if there is no such file
    if (rptFiles.length == 0) {
        clear();
        return;
    }
    File firstRPT = rptFiles[0];

    Scanner scanner;
    try {
        scanner = new Scanner(firstRPT);
        scanner.useDelimiter("\\s+|\n");
    } catch (FileNotFoundException ex) {
        clear();
        return;
    }
    List<Map.Entry<Double, Double>> tmpList = new ArrayList<>();
    for (int i = 0; scanner.hasNext(); i++) {
        String line = scanner.next();
        try {
            double x1 = Double.valueOf(line);
            line = scanner.next();
            double x2 = Double.valueOf(line);
            //                System.out.println("x1=" + x1 + "\nx2=" + x2);
            tmpList.add(new AbstractMap.SimpleEntry<>(x1, x2));
        } catch (NumberFormatException ex) {
            // only if it is the third or following line
            if (i > 1) {
                LOGGER.error("Error while parsing double from file: " + firstRPT.getAbsolutePath());
                JOptionPane.showMessageDialog(this, "Error while parsing result file.", "Parsing error",
                        JOptionPane.ERROR_MESSAGE);
            }
        }

    }
    if (tmpList.isEmpty()) {
        clear();
        return;
    }
    fillData(tmpList);

    //        fillData(tmpList, dataSeries, toleranceSeries);        
}

From source file:com.zilotti.hostsjuggler.view.ActiveHostsFileWindow.java

/**
 * Parses a hosts file and loads it into its corresponding Javabean 
 * representation./*from  www  .  ja v a  2 s . c o m*/
 *  
 * @param hostsFile
 * @return
 * @throws IOException
 */
private HostsFile loadHostsFile(File hostsFile) throws IOException, ParseException {
    /* Object to be returned */
    HostsFile hostsFileObject = new HostsFile();

    BufferedReader br = null;

    int lineCounter = 1;
    try {
        br = new BufferedReader(new FileReader(hostsFile));

        String line = null;
        while ((line = br.readLine()) != null) {
            line += "\n";

            /* Remark */
            if (line.startsWith(REM_LINE_CHAR)) {
                CommentLine commentLine = new CommentLine();
                commentLine.setLine(line);
                hostsFileObject.addLine(commentLine);
            } else if (StringUtils.isBlank(line)) // Blank line
            {
                BlankLine blankLine = new BlankLine();
                blankLine.setLine(line);
                hostsFileObject.addLine(blankLine);
            } else {
                Scanner scanner = new Scanner(line);
                HostLine hostLine = new HostLine();

                if (scanner.hasNext()) {
                    /* Expects an IP address */
                    String ipAddress = scanner.next();

                    if (NetworkUtils.isIpAddress(ipAddress)) {
                        hostLine.setIpAddress(ipAddress);
                    } else
                        throw new ParseException("Expected an IP address but found '" + ipAddress + "'",
                                lineCounter);

                    /* Expects a list of hostnames */
                    List<String> hostNames = new LinkedList<String>();
                    String hostName = null;
                    while (scanner.hasNext()) {
                        hostName = scanner.next();

                        if (NetworkUtils.isHostName(hostName)) {
                            hostNames.add(hostName);
                        } else
                            throw new ParseException("Expected a hostname but found '" + hostName + "'",
                                    lineCounter);
                    }

                    hostLine.setHostNames(hostNames);
                    hostLine.setLine(line);
                    hostsFileObject.addLine(hostLine);
                }
            }
        }
    } finally {
        if (br != null)
            br.close();
    }

    return hostsFileObject;
}

From source file:openscim.restful.server.resources.group.ldap.LdapGroupResource.java

@Override
public Response createGroup(UriInfo uriInfo, Group group) {
    // check the ldap template has been setup correctly
    if (ldapTemplate != null) {
        // create the mapper if it doesn't already exists
        if (mapper == null)
            mapper = new GroupAttributesMapper(properties);

        // build the group dn
        String dn = group.getId();
        if (properties
                .getProperty(GroupAttributesMapper.CONCEAL_GROUP_DNS,
                        GroupAttributesMapper.DEFAULT_CONCEAL_GROUP_DNS)
                .equalsIgnoreCase(GroupAttributesMapper.DEFAULT_CONCEAL_GROUP_DNS)) {
            // utilise ldap formated dn
            dn = properties.getProperty(GroupAttributesMapper.GID_ATTRIBUTE,
                    GroupAttributesMapper.DEFAULT_GID_ATTRIBUTE) + "=" + group.getId() + ","
                    + properties.getProperty(GroupAttributesMapper.GROUP_BASEDN,
                            GroupAttributesMapper.DEFAULT_GROUP_BASEDN);
        }/*from ww w .j av a  2  s . c  o  m*/

        try {
            try {
                // retrieve the group
                Group lookedGroup = (Group) ldapTemplate.lookup(dn, mapper);

                // check if the group was found
                if (lookedGroup != null) {
                    // user already exists            
                    return ResourceUtilities.buildErrorResponse(HttpStatus.CONFLICT,
                            HttpStatus.CONFLICT.getMessage() + ": Resource " + dn + " already exists");
                }
            } catch (Exception nException) {
                // group not found, do nothing
            }

            Attributes groupAttributes = new BasicAttributes();

            // get the objectclasses
            String objectclasses = properties.getProperty(GroupAttributesMapper.GROUP_OBJECTCLASS_ATTRIBUTE,
                    GroupAttributesMapper.DEFAULT_GROUP_OBJECTCLASS_ATTRIBUTE);

            // set the objectclass of the group
            Scanner scanner = new Scanner(objectclasses);
            scanner.useDelimiter(",");
            while (scanner.hasNext()) {
                groupAttributes.put("objectclass", scanner.next());
            }

            // set the gid
            String gidAtttributeName = properties.getProperty(GroupAttributesMapper.GID_ATTRIBUTE,
                    GroupAttributesMapper.DEFAULT_GID_ATTRIBUTE);
            groupAttributes.put(gidAtttributeName, group.getId());

            // get the member attribute name
            String memberAtttributeName = properties.getProperty(GroupAttributesMapper.MEMBER_ATTRIBUTE,
                    GroupAttributesMapper.DEFAULT_MEMBER_ATTRIBUTE);

            // set the members
            Attribute memberAttribute = new BasicAttribute(memberAtttributeName);
            if (group.getAny() instanceof List) {
                List members = (List) group.getAny();
                for (Object object : members) {
                    if (object instanceof PluralAttribute) {
                        PluralAttribute member = (PluralAttribute) object;
                        String uid = member.getValue();

                        // build the user dn
                        String userdn = uid;
                        if (properties.getProperty(UserAttributesMapper.CONCEAL_ACCOUNT_DNS, "true")
                                .equalsIgnoreCase("true")) {
                            // utilise ldap formated dn
                            userdn = properties.getProperty(UserAttributesMapper.UID_ATTRIBUTE,
                                    UserAttributesMapper.DEFAULT_UID_ATTRIBUTE) + "=" + uid + ","
                                    + properties.getProperty(UserAttributesMapper.ACCOUNT_BASEDN,
                                            UserAttributesMapper.DEFAULT_ACCOUNT_BASEDN);
                        }

                        memberAttribute.add(userdn);
                    }
                }
            }
            groupAttributes.put(memberAttribute);

            // create the group
            ldapTemplate.bind(dn, null, groupAttributes);

            // determine the url of the new resource
            URI location = new URI("/Group/" + dn);
            if (properties
                    .getProperty(GroupAttributesMapper.CONCEAL_GROUP_DNS,
                            GroupAttributesMapper.DEFAULT_CONCEAL_GROUP_DNS)
                    .equalsIgnoreCase(GroupAttributesMapper.DEFAULT_CONCEAL_GROUP_DNS)) {
                location = new URI("/User/" + group.getId());
            }

            // group stored successfully, return the group            
            return Response.created(location).entity(group).build();
        } catch (URISyntaxException usException) {
            // problem generating entity location
            logger.error("problem generating entity location");

            // return a server error
            return ResourceUtilities.buildErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR,
                    HttpStatus.NOT_IMPLEMENTED.getMessage()
                            + ": Service Provider problem generating entity location");
        } catch (Exception nException) {
            // problem creating group
            logger.error("problem creating group");

            // return a server error
            return ResourceUtilities.buildErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR,
                    HttpStatus.NOT_IMPLEMENTED.getMessage() + ": Service Provider problem creating group");
        }
    } else {
        // ldap not configured
        logger.error("ldap not configured");

        // return a server error
        return ResourceUtilities.buildErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR,
                HttpStatus.NOT_IMPLEMENTED.getMessage()
                        + ": Service Provider group ldap repository not configured");
    }
}