public static Set < String > computeDisplayedNamespace ( VisualizerInput input , List < Class < ? extends SNode > > types ) { if ( input == null ) { return new HashSet <> ( ) ; } String showNamespaceConfig = input . getMappings ( ) . getProperty ( GridComponent . MAPPING_SHOW_NAMESPACE ) ; if ( showNamespaceConfig != null ) { SDocumentGraph graph = input . getDocument ( ) . getDocumentGraph ( ) ; Set < String > annoPool = new LinkedHashSet <> ( ) ; for ( Class < ? extends SNode > t : types ) { annoPool . addAll ( SToken . class . isAssignableFrom ( t ) ? getAnnotationLevelSet ( graph , null , t ) : getAnnotationLevelSet ( graph , input . getNamespace ( ) , t ) ) ; } if ( "true" . equalsIgnoreCase ( showNamespaceConfig ) ) { // all annotations should be displayed with a namespace return annoPool ; } else if ( "false" . equalsIgnoreCase ( showNamespaceConfig ) ) { return new LinkedHashSet <> ( ) ; } else { Set < String > annos = new LinkedHashSet <> ( ) ; List < String > defs = Splitter . on ( ' ' ) . omitEmptyStrings ( ) . trimResults ( ) . splitToList ( showNamespaceConfig ) ; for ( String s : defs ) { // is regular expression? if ( s . startsWith ( "/" ) && s . endsWith ( "/" ) ) { // go over all remaining items in our pool of all annotations and // check if they match Pattern regex = Pattern . compile ( StringUtils . strip ( s , "/" ) ) ; LinkedList < String > matchingAnnos = new LinkedList <> ( ) ; for ( String a : annoPool ) { if ( regex . matcher ( a ) . matches ( ) ) { matchingAnnos . add ( a ) ; } } annos . addAll ( matchingAnnos ) ; annoPool . removeAll ( matchingAnnos ) ; } else { annos . add ( s ) ; annoPool . remove ( s ) ; } } return annos ; } } return new LinkedHashSet <> ( ) ; }
Returns the annotations to which should be displayed together with their namespace .