public StyleResolverCacheEntry( final StyleResolverCacheEntry parentEntry, final ReportElement e ) { if ( parentEntry == null ) { this.elementChangeTracker = e.getChangeTracker(); this.styleChangeHash = e.getStyle().getChangeTrackerHash(); this.styleModificationCount = e.getStyle().getModificationCount(); } else { this.elementChangeTracker = parentEntry.getElementChangeTracker() * 31 + e.getChangeTracker(); this.styleChangeHash = parentEntry.getStyleChangeHash() * 31 + e.getStyle().getChangeTrackerHash(); this.styleModificationCount = parentEntry.getStyleModificationCount() * 31 + e.getStyle().getModificationCount(); } }
public void addInherited( final ElementStyleSheet sourceStyleSheet ) { super.addInherited( sourceStyleSheet ); setChangeTrackerHash( getChangeTrackerHash() * 31 + sourceStyleSheet.getChangeTrackerHash() ); setModificationCount( getModificationCount() * 31 + sourceStyleSheet.getModificationCount() ); }
public void addDefault( final ElementStyleSheet sourceStyleSheet ) { super.addDefault( sourceStyleSheet ); setChangeTrackerHash( getChangeTrackerHash() * 31 + sourceStyleSheet.getChangeTrackerHash() ); setModificationCount( getModificationCount() * 31 + sourceStyleSheet.getModificationCount() ); }
public void addAll( final ElementStyleSheet sourceStyleSheet ) { super.addAll( sourceStyleSheet ); setChangeTrackerHash( getChangeTrackerHash() * 31 + sourceStyleSheet.getChangeTrackerHash() ); setModificationCount( getModificationCount() * 31 + sourceStyleSheet.getModificationCount() ); }
@Test public void copyFrom_OnChangedSheet() { List<StyleKey> keys = StyleKey.getDefinedStyleKeysList(); ElementStyleSheet sheet = new ElementStyleSheet(); setEverySecondKey( sheet, keys ); ElementStyleSheet another = new ElementStyleSheet(); another.copyFrom( sheet ); assertEquals( sheet.getModificationCount(), another.getModificationCount() ); assertEquals( sheet.getChangeTrackerHash(), another.getChangeTrackerHash() ); assertEverySecondKey( another, keys ); for ( int i = 0; i < keys.size(); i += 2 ) { StyleKey key = keys.get( i ); assertTrue( another.isLocalKey( key ) ); } }
@Test public void clearsCorrectly() { List<StyleKey> keys = StyleKey.getDefinedStyleKeysList(); ElementStyleSheet sheet = new ElementStyleSheet(); setEverySecondKey( sheet, keys ); sheet.clear(); assertEquals( 0, sheet.getModificationCount() ); assertEquals( 0, sheet.getChangeTrackerHash() ); for ( int i = 0; i < keys.size(); i += 2 ) { StyleKey key = keys.get( i ); Object property = sheet.getStyleProperty( key ); assertNull( property ); } }
@Test public void copyFrom_OnIntactSheet_SameAsClearing() { List<StyleKey> keys = StyleKey.getDefinedStyleKeysList(); ElementStyleSheet sheet = new ElementStyleSheet(); setEverySecondKey( sheet, keys ); sheet.copyFrom( new ElementStyleSheet() ); assertEquals( 0, sheet.getModificationCount() ); assertEquals( 0, sheet.getChangeTrackerHash() ); for ( int i = 0; i < keys.size(); i += 2 ) { StyleKey key = keys.get( i ); Object property = sheet.getStyleProperty( key ); assertNull( property ); } }