This method verifies if aSourceAnnotation can ve inserted safety into the aTargetAnnotSet. Safety means that it doesn't violate the crossed over contition with any annotation from the aTargetAnnotSet. @param aTargetAnnotSet the annotation set to include the aSourceAnnotation @param aSource
(AnnotationSet aTargetAnnotSet,
Annotation aSourceAnnotation)
| 899 | * @return true if the annotation inserts safety, or false otherwise. |
| 900 | */ |
| 901 | private boolean insertsSafety(AnnotationSet aTargetAnnotSet, |
| 902 | Annotation aSourceAnnotation) { |
| 903 | if(aTargetAnnotSet == null || aSourceAnnotation == null) { |
| 904 | this.crossedOverAnnotation = null; |
| 905 | return false; |
| 906 | } |
| 907 | if(aSourceAnnotation.getStartNode() == null |
| 908 | || aSourceAnnotation.getStartNode().getOffset() == null) { |
| 909 | this.crossedOverAnnotation = null; |
| 910 | return false; |
| 911 | } |
| 912 | if(aSourceAnnotation.getEndNode() == null |
| 913 | || aSourceAnnotation.getEndNode().getOffset() == null) { |
| 914 | this.crossedOverAnnotation = null; |
| 915 | return false; |
| 916 | } |
| 917 | // Get the start and end offsets |
| 918 | Long start = aSourceAnnotation.getStartNode().getOffset(); |
| 919 | Long end = aSourceAnnotation.getEndNode().getOffset(); |
| 920 | // Read aSourceAnnotation offsets long |
| 921 | long s2 = start.longValue(); |
| 922 | long e2 = end.longValue(); |
| 923 | // Obtain a set with all annotations annotations that overlap |
| 924 | // totaly or partially with the interval defined by the two provided offsets |
| 925 | AnnotationSet as = aTargetAnnotSet.get(start, end); |
| 926 | // Investigate all the annotations from as to see if there is one that |
| 927 | // comes in conflict with aSourceAnnotation |
| 928 | Iterator<Annotation> it = as.iterator(); |
| 929 | while(it.hasNext()) { |
| 930 | Annotation ann = it.next(); |
| 931 | // Read ann offsets |
| 932 | long s1 = ann.getStartNode().getOffset().longValue(); |
| 933 | long e1 = ann.getEndNode().getOffset().longValue(); |
| 934 | if(s1 < s2 && s2 < e1 && e1 < e2) { |
| 935 | this.crossedOverAnnotation = ann; |
| 936 | return false; |
| 937 | } |
| 938 | if(s2 < s1 && s1 < e2 && e2 < e1) { |
| 939 | this.crossedOverAnnotation = ann; |
| 940 | return false; |
| 941 | } |
| 942 | }// End while |
| 943 | return true; |
| 944 | }// insertsSafety() |
| 945 | |
| 946 | private boolean insertsSafety(List<Annotation> aTargetAnnotList, |
| 947 | Annotation aSourceAnnotation) { |
no test coverage detected