uid = $uid; $this->userManager = $userManager; $this->displayName = $displayName; $this->backend = $backend; } private function getUser(): IUser { if ($this->user === null) { if ($this->backend) { /** @var \OC\User\Manager $manager */ $manager = $this->userManager; $this->user = $manager->getUserObject($this->uid, $this->backend); } else { $this->user = $this->userManager->get($this->uid); } } if ($this->user === null) { throw new NoUserException('User not found in backend'); } return $this->user; } public function getUID() { return $this->uid; } public function getDisplayName() { if ($this->displayName) { return $this->displayName; } return $this->userManager->getDisplayName($this->uid) ?? $this->uid; } public function setDisplayName($displayName) { return $this->getUser()->setDisplayName($displayName); } public function getLastLogin(): int { return $this->getUser()->getLastLogin(); } public function getFirstLogin(): int { return $this->getUser()->getFirstLogin(); } public function updateLastLoginTimestamp(): bool { return $this->getUser()->updateLastLoginTimestamp(); } public function delete() { return $this->getUser()->delete(); } public function setPassword($password, $recoveryPassword = null) { return $this->getUser()->setPassword($password, $recoveryPassword); } public function getPasswordHash(): ?string { return $this->getUser()->getPasswordHash(); } public function setPasswordHash(string $passwordHash): bool { return $this->getUser()->setPasswordHash($passwordHash); } public function getHome() { return $this->getUser()->getHome(); } public function getBackendClassName() { return $this->getUser()->getBackendClassName(); } public function getBackend(): ?UserInterface { return $this->getUser()->getBackend(); } public function canChangeAvatar() { return $this->getUser()->canChangeAvatar(); } public function canChangePassword() { return $this->getUser()->canChangePassword(); } public function canChangeDisplayName() { return $this->getUser()->canChangeDisplayName(); } public function canChangeEmail(): bool { return $this->getUser()->canChangeEmail(); } public function isEnabled() { return $this->getUser()->isEnabled(); } public function setEnabled(bool $enabled = true) { return $this->getUser()->setEnabled($enabled); } public function getEMailAddress() { return $this->getUser()->getEMailAddress(); } public function getSystemEMailAddress(): ?string { return $this->getUser()->getSystemEMailAddress(); } public function getPrimaryEMailAddress(): ?string { return $this->getUser()->getPrimaryEMailAddress(); } public function getAvatarImage($size) { return $this->getUser()->getAvatarImage($size); } public function getCloudId() { return $this->getUser()->getCloudId(); } public function setEMailAddress($mailAddress) { $this->getUser()->setEMailAddress($mailAddress); } public function setSystemEMailAddress(string $mailAddress): void { $this->getUser()->setSystemEMailAddress($mailAddress); } public function setPrimaryEMailAddress(string $mailAddress): void { $this->getUser()->setPrimaryEMailAddress($mailAddress); } public function getQuota() { return $this->getUser()->getQuota(); } public function setQuota($quota) { $this->getUser()->setQuota($quota); } public function getManagerUids(): array { return $this->getUser()->getManagerUids(); } public function setManagerUids(array $uids): void { $this->getUser()->setManagerUids($uids); } } dle/com.github.spotbugs-6.2.2'>dependabot/gradle/com.github.spotbugs-6.2.2 Mirror of Apache POI: https://github.com/apache/poiwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/poi/ss/format/CellNumberStringMod.java
blob: a053206a87115d920b3a5115c67cd3acddcb9ff5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* ====================================================================
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
==================================================================== */
package org.apache.poi.ss.format;

import org.apache.poi.ss.format.CellNumberFormatter.Special;
import org.apache.poi.util.Internal;

/**
 * Internal helper class for CellNumberFormatter
 *
 * This class represents a single modification to a result string.  The way
 * this works is complicated, but so is numeric formatting.  In general, for
 * most formats, we use a DecimalFormat object that will put the string out
 * in a known format, usually with all possible leading and trailing zeros.
 * We then walk through the result and the original format, and note any
 * modifications that need to be made.  Finally, we go through and apply
 * them all, dealing with overlapping modifications.
 */
@Internal
public class CellNumberStringMod implements Comparable<CellNumberStringMod> {
    public static final int BEFORE = 1;
    public static final int AFTER = 2;
    public static final int REPLACE = 3;

    private final Special special;
    private final int op;
    private CharSequence toAdd;
    private Special end;
    private boolean startInclusive;
    private boolean endInclusive;

    public CellNumberStringMod(Special special, CharSequence toAdd, int op) {
        this.special = special;
        this.toAdd = toAdd;
        this.op = op;
    }

    public CellNumberStringMod(Special start, boolean startInclusive, Special end, boolean endInclusive, char toAdd) {
        this(start, startInclusive, end, endInclusive);
        this.toAdd = toAdd + "";
    }

    public CellNumberStringMod(Special start, boolean startInclusive, Special end, boolean endInclusive) {
        special = start;
        this.startInclusive = startInclusive;
        this.end = end;
        this.endInclusive = endInclusive;
        op = REPLACE;
        toAdd = "";
    }

    public int compareTo(CellNumberStringMod that) {
        int diff = special.pos - that.special.pos;
        return (diff != 0) ? diff : (op - that.op);
    }

    @Override
    public boolean equals(Object that) {
        try {
            return compareTo((CellNumberStringMod) that) == 0;
        } catch (RuntimeException ignored) {
            // NullPointerException or CastException
            return false;
        }
    }

    @Override
    public int hashCode() {
        return special.hashCode() + op;
    }

    public Special getSpecial() {
        return special;
    }

    public int getOp() {
        return op;
    }

    public CharSequence getToAdd() {
        return toAdd;
    }

    public Special getEnd() {
        return end;
    }

    public boolean isStartInclusive() {
        return startInclusive;
    }

    public boolean isEndInclusive() {
        return endInclusive;
    }
}