sPFFramework/src/main/java/it/polimi/spf/framework/profile/ProfileTable.java
private List<String> visibleFields(PersonAuth pAuth, SPFPersona persona, String[] fields) {
		SQLiteDatabase db = getReadableDatabase();
		String table = Contract.TABLE_VISIBILITY;
		String[] columns = { Contract.COLUMN_KEY, Contract.COLUMN_CIRCLE };
		String inClause = getInClause(fields);
		String selection = Contract.COLUMN_PERSONA + " = ? AND " + Contract.COLUMN_KEY + " IN " + inClause;
		String[] selectionArgs = { persona.getIdentifier() };
		String groupBy = null;
		String having = null;
		String orderBy = null;
		Cursor c = db.query(table, columns, selection, selectionArgs, groupBy, having, orderBy);
		
		List<String> fieldKeys = new ArrayList<String>();
		List<String> privateFields = new ArrayList<String>();
		boolean allCircles = pAuth.getCircles().contains(DefaultCircles.ALL_CIRCLE);

		while (c.moveToNext()) {
			String key = c.getString(c.getColumnIndex(Contract.COLUMN_KEY));
			String circle = c.getString(c.getColumnIndex(Contract.COLUMN_CIRCLE));
			if (circle.equals(DefaultCircles.PRIVATE)){
				privateFields.add(circle);
			} else if (allCircles || pAuth.getCircles().contains(circle)) {
				fieldKeys.add(key);
			}
		}
		c.close();
		fieldKeys.removeAll(privateFields);
		return fieldKeys;
	}
private List<String> visibleFields(PersonAuth pAuth, SPFPersona persona, String[] fields) {
		SQLiteDatabase db = getReadableDatabase();
		String table = Contract.TABLE_VISIBILITY;
		String[] columns = { Contract.COLUMN_KEY, Contract.COLUMN_CIRCLE };
		String inClause = getInClause(fields);
		String selection = Contract.COLUMN_PERSONA + " = ? AND " + Contract.COLUMN_KEY + " IN " + inClause;
		String[] selectionArgs = { persona.getIdentifier() };
		String groupBy = null;
		String having = null;
		String orderBy = null;
		Cursor c = db.query(table, columns, selection, selectionArgs, groupBy, having, orderBy);
		
		List<String> fieldKeys = new ArrayList<String>();
		List<String> privateFields = new ArrayList<String>();
		boolean allCircles = pAuth.getCircles().contains(DefaultCircles.ALL_CIRCLE);

		while (c.moveToNext()) {
			String key = c.getString(c.getColumnIndex(Contract.COLUMN_KEY));
			String circle = c.getString(c.getColumnIndex(Contract.COLUMN_CIRCLE));
			if (circle.equals(DefaultCircles.PRIVATE)){
				privateFields.add(circle);
			} else if (allCircles || pAuth.getCircles().contains(circle)) {
				fieldKeys.add(key);
			}
		}
		c.close();
		fieldKeys.removeAll(privateFields);
		return fieldKeys;
	}
private List < String > visibleFields ( PersonAuth pAuth , SPFPersona persona , String [ ] fields ) { SQLiteDatabase db = getReadableDatabase ( ) ; String table = Contract . TABLE_VISIBILITY ; String [ ] columns = { Contract . COLUMN_KEY , Contract . COLUMN_CIRCLE } ; String inClause = getInClause ( fields ) ; String selection = Contract . COLUMN_PERSONA + " = ? AND " + Contract . COLUMN_KEY + " IN " + inClause ; String [ ] selectionArgs = { persona . getIdentifier ( ) } ; String groupBy = null ; String having = null ; String orderBy = null ; Cursor c = db . query ( table , columns , selection , selectionArgs , groupBy , having , orderBy ) ; List < String > fieldKeys = new ArrayList < String > ( ) ; List < String > privateFields = new ArrayList < String > ( ) ; boolean allCircles = pAuth . getCircles ( ) . contains ( DefaultCircles . ALL_CIRCLE ) ; while ( c . moveToNext ( ) ) { String key = c . getString ( c . getColumnIndex ( Contract . COLUMN_KEY ) ) ; String circle = c . getString ( c . getColumnIndex ( Contract . COLUMN_CIRCLE ) ) ; if ( circle . equals ( DefaultCircles . PRIVATE ) ) { privateFields . add ( circle ) ; } else if ( allCircles || pAuth . getCircles ( ) . contains ( circle ) ) { fieldKeys . add ( key ) ; } } c . close ( ) ; fieldKeys . removeAll ( privateFields ) ; return fieldKeys ; }
Filters the parameter fields and retruns only the field that can be
accessed given the permission provided with the {@link PersonAuth}
parameter.

@param pAuth
- the permissions
@param persona
- the {@link SPFPersona} to read
@param fields
- the fields' identifiers to filter
@return a list of accessible fields
Filters the parameter fields and retruns only the field that can be accessed given the permission provided with the { @link PersonAuth } parameter .