Back to project page PasswordDroid.
The source code is released under:
GNU General Public License
If you think the Android project PasswordDroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package de.wuthoehle.passworddroid.service.model.entries; //from w w w. ja v a2 s . c om /* Copyright (c) 2015 Marco Huenseler <marcoh.huenseler+git@gmail.com> * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ public class Customizable implements EntryElement { public static final byte ID_UPPER_CASE = 1; public static final byte ID_LOWER_CASE = 2; public static final byte ID_NUMBERS = 4; public static final byte ID_SPECIAL = 8; public static final String CHARACTERS_UPPER_CASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; public static final String CHARACTERS_LOWER_CASE = "abcdefghijklmnopqrstuvwxyz"; public static final String CHARACTERS_NUMBERS = "0123456789"; public static final String CHARACTERS_SPECIAL = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"; private Entry parent; private String characters; private String ud_characters; private int length; private byte mask; public Customizable(Entry parent, byte mask, String ud_characters, int length) { this.parent = parent; this.mask = mask; setCharacters(mask); setCharacters(ud_characters); this.length = length; this.parent.setPassword_known(false); } public Customizable(Entry parent, byte mask, int length) { this(parent, mask, "", length); } public String getCharacters() { return this.characters + this.ud_characters; } public void setCharacters(byte mask) { String characters = ""; // 1-bit is set if ((mask & 0b1) == ID_UPPER_CASE) { characters += CHARACTERS_UPPER_CASE; } // 2-bit is set if ((mask & 0b10) == ID_LOWER_CASE) { characters += CHARACTERS_LOWER_CASE; } // 4-bit is set if ((mask & 0b100) == ID_NUMBERS) { characters += CHARACTERS_NUMBERS; } // 8-bit is set if ((mask & 0b1000) == ID_SPECIAL) { characters += CHARACTERS_SPECIAL; } this.characters = characters; this.parent.setPassword_known(false); } public String getAdditionalCharacters() { return this.ud_characters; } public void setCharacters(String characters) { this.ud_characters = characters; this.parent.setPassword_known(false); } public int getLength() { return this.length; } public void setLength(int length) { this.length = length; parent.setPassword_known(false); } public byte getMask() { return this.mask; } public void setMask(byte mask) { this.mask = mask; setCharacters(mask); parent.setPassword_known(false); } @Override public void accept(EntryVisitor visitor) { visitor.visit(this); } }