Changeset 15217 in josm for trunk/src/com/drew/metadata/tiff
- Timestamp:
- 2019-07-07T01:56:46+02:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/drew/metadata/tiff/DirectoryTiffHandler.java
r13061 r15217 1 1 /* 2 * Copyright 2002-201 7Drew Noakes2 * Copyright 2002-2019 Drew Noakes and contributors 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); … … 24 24 import com.drew.lang.Rational; 25 25 import com.drew.lang.annotations.NotNull; 26 import com.drew.lang.annotations.Nullable; 26 27 import com.drew.metadata.Directory; 27 28 import com.drew.metadata.ErrorDirectory; … … 40 41 private final Stack<Directory> _directoryStack = new Stack<Directory>(); 41 42 42 protected Directory _currentDirectory; 43 @Nullable private Directory _rootParentDirectory; 44 @Nullable protected Directory _currentDirectory; 43 45 protected final Metadata _metadata; 44 46 45 protected DirectoryTiffHandler(Metadata metadata) 47 protected DirectoryTiffHandler(Metadata metadata, @Nullable Directory parentDirectory) 46 48 { 47 49 _metadata = metadata; 50 _rootParentDirectory = parentDirectory; 48 51 } 49 52 … … 55 58 protected void pushDirectory(@NotNull Class<? extends Directory> directoryClass) 56 59 { 57 Directory newDirectory = null;60 Directory newDirectory; 58 61 59 62 try { … … 65 68 } 66 69 67 if (newDirectory != null) 68 { 69 // If this is the first directory, don't add to the stack 70 if (_currentDirectory != null) 71 { 72 _directoryStack.push(_currentDirectory); 73 newDirectory.setParent(_currentDirectory); 70 // If this is the first directory, don't add to the stack 71 if (_currentDirectory == null) { 72 // Apply any pending root parent to this new directory 73 if (_rootParentDirectory != null) { 74 newDirectory.setParent(_rootParentDirectory); 75 _rootParentDirectory = null; 74 76 } 75 _currentDirectory = newDirectory;76 _metadata.addDirectory(_currentDirectory);77 77 } 78 else { 79 // The current directory is pushed onto the stack, and set as the new directory's parent 80 _directoryStack.push(_currentDirectory); 81 newDirectory.setParent(_currentDirectory); 82 } 83 84 _currentDirectory = newDirectory; 85 _metadata.addDirectory(_currentDirectory); 78 86 } 79 87
Note:
See TracChangeset
for help on using the changeset viewer.